Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Web APIを理解する
Search
taminif
July 15, 2017
Programming
0
300
Web APIを理解する
php conference Kansai 2017
本編LT枠
taminif
July 15, 2017
Tweet
Share
More Decks by taminif
See All by taminif
PuppeteerとPlaywrightの15日間の演劇 / relation of Puppeteer and Playwright
taminif
3
2k
Redashの開発はじめました / How to get started Redash development
taminif
0
710
私の生活を変えたHeadless Chrome / Headless Chrome who changed my life
taminif
3
420
WebSocketをiOSに持ち込んで辛い思いをした経験がありますか!? / have you painful experience in web socket?
taminif
3
5.3k
LINEで馬券を購入する / Purchase a betting ticket at LINE
taminif
1
1.5k
SkyWayで一年間運用してきたけどWebRTCってつらいんじゃないの
taminif
2
950
オンライン英会話とSkyWay
taminif
0
460
オンライン英会話アプリとSkyWay
taminif
0
410
Mac1台でアプリを作る時代再び
taminif
0
400
Other Decks in Programming
See All in Programming
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.2k
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
1
110
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
990
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
ヤプリ新卒SREの オンボーディング
masaki12
0
130
初めてDefinitelyTypedにPRを出した話
syumai
0
420
Quine, Polyglot, 良いコード
qnighy
4
650
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
GitHub's CSS Performance
jonrohan
1030
460k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
A designer walks into a library…
pauljervisheath
204
24k
Unsuck your backbone
ammeep
668
57k
Visualization
eitanlees
145
15k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Building Applications with DynamoDB
mza
90
6.1k
Why Our Code Smells
bkeepers
PRO
334
57k
Transcript
Web APIΛཧղ͢Δ php conference Kansai 2017 ຊฤLT 2017/07/15 େౡ ޫو@sbntaminif
ࣗݾհ • ΣϒϦΦגࣜձࣾWEBΤϯδχΞ • ීஈژͰಇ͍͍ͯ·͢ • ඈͼೖΓࢀՃͱ͍͏͜ͱͰ ٸᬎ͜ͷϓϨθϯΛ࡞Γ·ͨ͠ʂ
Web APIͷઆ໌
௨ৗͷHTTP௨৴ ϒϥβ 1)1αʔόʔ ϦΫΤετ )5.-
APIͷHTTP௨৴ ϒϥβ 1)1αʔόʔ ϦΫΤετ Կ͔͠Βͷ
ͬͯΔ͜ͱ ಉ͡Ͱ͢ʂ
ϒϥβ͕ཧղ͢Δඞཁ͕ ͳ͍ͷͰɺʢ࣮࣭ʣͲΜͳ Ͱฦͤ·͢ɻ
Ͳ͏͍͏࣌ʹ༻͢Δͷ͔
APIͷ༻్ • APIલఏͷγεςϜઃܭ࣌ • ΞϓϦͰใΛऔಘ͢Δ࣌ • ୈࡾऀʹใΛఏڙ͢Δ࣌
REST APIͱ͍͏ ߟ͑ํ
REST APIͱ • ιϑτΣΞΞʔΩςΫνϟͷҰͭ Web APIͰଟ͘࠾༻͞Ε͍ͯΔ • URLHTTP ϝιουͳͲWebͷ੍ʹैΘͤΔ͜ ͱͰڞ௨ཧղΛ࣋ͭ
• TwitterGithubͷAPI RESTͷਪʹैͬͯఏڙ͞Ε͍ͯΔ
αϯϓϧʢGitHub APIʣΛͬͯઆ໌ https://api.github.com/repos ->GETͰΞΫηε->ϨϙδτϦҰཡΛऔಘ ->POSTͰΞΫηε->ϨϙδτϦΛՃ “repos”(ϦϙδτϦ)ͱ͍͏ϦιʔεΛ ૢ࡞͢ΔAPIͱͳΔ ΤϯυϙΠϯτ Ϧιʔε
REST APIͷਪ࣮ ʢϝιουʣ • GETऔಘ • POSTՃ • PUTมߋ •
DELETEআ
REST APIͷਪ࣮ ʢϝιουʣ • GETऔಘ -> R(Read) • POSTՃ ->
C(Create) • PUTߋ৽ -> U(Update) • DELETEআ -> D(Delete) ->σʔλʢϦιʔεʣʹରͯ͠ૢ࡞
REST APIͷਪ࣮ʢURLʣ • Ϧιʔε෦తޠͷෳܗ • usersʢձһʣ • tagsʢλάʣ • Ͱ͖Δ͚ͩ͘ɺར༻ऀʹΘ͔Γ໊͍͢
લΛ͚ͭΔ
REST APIͷਪ࣮ ʢHTTP Responseͦͷ1ʣ • 200൪ΞΫηεʹޭͨ͠߹ʹฦ͢ • 200OK 201Created
REST APIͷਪ࣮ ʢHTTP Responseͦͷ2ʣ • 400൪ΫϥΠΞϯτʹ͕͋Δ߹ʹฦ͢ • 401ೝূ͕ඞཁͳURL 404ͦͦଘࡏ͠ͳ͍URL •
500൪αʔόʹ͕͋Δ߹ʹฦ͢
REST APIʹैࣄ͢Δ͜ͱͰ Θ͔Γ͍͢APIΛ ઃܭ͠·͠ΐ͏
ࢀߟɿWeb API The Good Parts https://www.amazon.co.jp/exec/obidos/ASIN/4873116864/
͋Γ͕ͱ͏͍͟͝·ͨ͠