Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WordPress RESTful API & Amazon API Gateway - WordCamp Kansai 2016

3,329 views

Published on

July 10, 2016

Published in: Technology

WordPress RESTful API & Amazon API Gateway - WordCamp Kansai 2016

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Takayuki Shimizu @shimy_net Solutions Architect, Amazon Web Services Japan K.K. July 10, 2016 D : GG IA & & MDC & H WordCamp Kansai 2016
  2. 2. & DIH . •  I MI 0 QRVbIWN & •  n l •  HHE GA : G C H G C H RLT J 53) f f f 1 5 1 5 1 Kb RWN R f 2RTN R Q 4bWJV 42f @b QJP J C R LQ 1 VJ R W
  3. 3. T l _a AWS IoT T
  4. 4. What to Expect from the Session 1.  REST API ? 2.  j WordPress 3.  Amazon API Gateway ? 4.  j j REST API 5.  WordPress j 6. 
  5. 5. •  N NW J R WJU J N JW ON •  B b RNUMRWP u GNK j ( •  B5CD 1@9 B5CDO U qr REST API m R
  6. 6. Resources •  BN LN p x •  •  j •  •  BN LN EB9 •  EB9 u BN LN •  EB9 j ( ( •  g n o ” ug n o ” x q
  7. 7. URI •  WRO V N LN MNW RdN •  BN LN •  mQ . J R NaJV UN L V N LN () •  •  pv BN LN p q •  EB9 u q u l m
  8. 8. HTTP method •  EB9 j rt •  DD@ y q •  5D @?CD @ED 45 5D5 s @1D3 mp 5D j B514 @?CD j 3B51D5 @ED j l EB9m j l EB9m E@41D5 3B51D5 45 5D5 j 45 5D5 @1D3 j E@41D5
  9. 9. HTTP status code “ T “ T ) ? g 5D j ) ( 3B51D54 g v y j u y @?CD j ) ? 3? D5 D ug u q 45 5D5 214 B5AE5CD h ust q y q q g :C? j ust q ( E 1ED ?B9H54 u u EB g ?B29445 j “ u y q j ?D ?E 4 j u t t q j “ 5D - 3? B93D j i r j u j j , 9 D5B 1 C5BF5B 5BB?B j j j j
  10. 10. Stateless •  j q •  l m p fix •  q j u
  11. 11. Stateful y eu rg T R bid R T bid l e lf_R lf T T bid
  12. 12. Stateless T T bid T T l bid T T m T lbid T T m T lbid y eu rg T R R l e lf_R lf
  13. 13. API proliferation The number of published APIs is growing rapidly 2418 10302 0 2000 4000 6000 8000 10000 12000 Jun-05 Oct-05 Feb-06 Jun-06 Oct-06 Feb-07 Jun-07 Oct-07 Feb-08 Jun-08 Oct-08 Feb-09 Jun-09 Oct-09 Feb-10 Jun-10 Oct-10 Feb-11 Jun-11 Oct-11 Feb-12 Jun-12 Oct-12 Feb-13 Jun-13 Oct-13 * Data from ProgrammableWeb
  14. 14. WordPress o T fzo R Weather information 3rd party API
  15. 15. •  2JLTNWM ! I NV NIPN I NV NI N L •  W NWM !1SJa R Q SA N b 1WP UJ :C BNJL N L T t s JSON 3rd party API Browser HTML Browser 3rd party API HTML JSON
  16. 16. •  2JLTNWM ! I NV NIPN I NV NI N L •  W NWM !1SJa R Q SA N b 1WP UJ :C BNJL N L b 3rd party API z cl n JSON Browser HTML Browser HTML JSON 3rd party API 3rd party API 3rd party API 3rd party API 3rd party API 3rd party API
  17. 17. API U “ fzp 1@9 j 1@9 g 1@9 1@9 t s
  18. 18. Amazon API Gateway
  19. 19. Amazon API Gateway l API b j j 1@9 j sw 1GC CRPF 1GC JVKMJ u
  20. 20. rrlp im Internet Mobile Apps Websites Services AWS ELB T T v“
  21. 21. Amazon API Gateway ny Internet Mobile Apps Websites Services API Gateway AWS Lambda functions AWS API Gateway Cache Amazon CloudWatch Amazon DynamoDB Endpoints on Amazon EC2 / Amazon Elastic Beanstalk Any other publicly accessible endpoint
  22. 22. Amazon API Gateway ny Internet Mobile Apps Websites Services API Gateway AWS Lambda functions AWS API Gateway Cache Amazon CloudWatch Amazon DynamoDB Endpoints on Amazon EC2 / Amazon Elastic Beanstalk Any other publicly accessible endpoint
  23. 23. wz T T(IaaS) n “ T “ T “ T T”“
  24. 24. Case 1. API PHP l T e WP o JSONHTML Browser 4bWJV 42 DJKUN c HGe JVKMJ WL R W c H HGe 1@9 G E HG 5D &
  25. 25. H &
  26. 26. H GDI
  27. 27. H O . H D:
  28. 28. Lambda Function “getPets” j j t
  29. 29. DynamoDB Table “Pets” j j sv
  30. 30. API Endpoint @?CD 1
  31. 31. wp_remote_get() l API _y T
  32. 32. l eh T
  33. 33. & fzpo S
  34. 34. Case 2. JavaScript l T ek WP o JSON HTML Browser JavaScript 4bWJV 42 DJKUN c HGe JVKMJ WL R W c H HGe 1@9 G E HG 5D &
  35. 35. JavaScript
  36. 36. Cross-Origin Request is Blocked ! Browser 4bWJV 42 DJKUN c HGe JVKMJ WL R W c H HGe 1@9 G E HG 5D A-site / CW B-site CORS A-site :
  37. 37. Enable CORS 1@9 j u 1@9 t w g j y 3 ? RPRW BN LN CQJ RWP !3?BC up h
  38. 38. J EH l eh T
  39. 39. S3 EC2CloudFront API Gateway Lambda DynamoDB StaticPress REST API Browser JavaScript
  40. 40. Amazon API Gateway Internet Mobile Apps Websites Services API Gateway AWS Lambda functions AWS API Gateway Cache Amazon CloudWatch Amazon DynamoDB Endpoints on Amazon EC2 / Amazon Elastic Beanstalk Any other publicly accessible endpoint
  41. 41. Case 3. API “ ek hn API Custom API Origin API A N b C RWP BNZ N NJMN C J 3 MN BN W N NJMN Stock API Map API Weather API1@9 Custom API
  42. 42. HTTP Proxy
  43. 43. WP REST API m R •  j w g DD@ j B5CD 1@9 •  G M@ N j jg g jg j DD@ x g j x u http://v2.wp-api.org/ j
  44. 44. p o REST API JSON WP REST API Frontend Backend iOS Android Tablet Fire Android iOS Tablet
  45. 45. GET /wp-json/wp/v2/posts
  46. 46. “ n ma WP REST API GET /wp-json/wp/v2/posts
  47. 47. WP REST API “ ma GET /wp-json/wp/v2/posts
  48. 48. Case 4. v“ l API Gateway API Gateway Cache Amazon CloudWatch GET /wp-json/wp/v2/posts WP REST API
  49. 49. P“
  50. 50. rmt •  B5CD 1@9 •  G M@ N B5CD 1@9 j •  l@ @m •  l:J_JCL R m •  DD@ @ ab 1@9 •  G@ B5CD 1@9 k •  CN _N UN G M@ N /
  51. 51. S
  52. 52. Thank you !

×