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.
kgf WP REST AP! 
0
Quién soy

 

Ant0niO Villegas eavillegasn

9nEI_Ic1
". i WP REST API
C

JSON + REST + API
JSON

JavaScript Object Notation

IIIDII:  3’
"title":  “IHo1a,  mundol", 
"content":  "Esta es tu primera entrada. "

- E...
REST

(Representational State Transfer)

- Protocolo clientelservidor sin estado

- HTTP para obtener datos o indicar Ia e...
Acciones PEST

Accién
(HTTP)

POST

GET

PUT

DELETE

Recurso
(Objeto)

/  posts

/  posts
/ posts/5

/ posts/5

/ posts/5...
API

Application Programming Interface

Una API es conjunto de funciones proporcionadas por cierto software
como herramien...
(-

 

tit;  WordPress AP| s .  wows

C‘ Q https: //codex. wordpress. org/ WordPress_APls

Cit‘, 

WordPress APls

The Wor...
WP REST API

Acceso y manipulacién de contenidos desde fuera de WordPress

Posts /  /  /  / 
Péginas /  /  /  / 
Custom Po...
tot REST API Resources i on

C‘ [:1 https, ‘i/ deve| oper. wordpress. contidocslapii‘

@Developers Documentation Blog MyAp...
FE

fir

l~I‘l; i‘(ci‘ , -.l. ... .l

Uri w: :i»jic-I»:  C'_l;4
tfi XML RPC womprr, -ss A

(- C‘ Q huos coaex. wordpiess. org xv «- .   w 1-‘v-~ ‘ Aw 5

Ci‘;  WORDPRESSORC; 

Showcase The...
(-

~_u, l

 

twovavmss»Jsowtrl-i -
C _“ httos/ /wordpress.0r9/Dlt. girs. l_son—apl/ 

 JSON API

Dnpitlrlr

; aV(W? (=<
...
JSON REST API
Ryan Mccue

o-gnunuon:  wawmu

Anlunod nmnnn:  Brynn Pony

Alanna:  Al -no momml ma only ma API In aa: cuwP ...
(-

 

J .  1:4} all J all i It

   

V Woraflrou .  JSON REST

_

C‘ ‘i nttps: /tmake. wordpress. org/ core/2013/06/17/, s...
A J        . 
Meet the Te m

,5_~_{v(¢-r.  2:’ 7 W 

1
Versiones

- Version 0.1 (Junio 2013)

- Version 0.1.1 (Junio 2013) a Version 0.9 (Abril 2014)

- Version 0.6 — GSoC Final...
La Pregunta. ..

; F~.  : ; ; ill ii
] l
. . it , 
T 1‘!  H‘-'5 3 1 If
‘T:  ll ‘
I
! ‘ s
u -.  ._
ll w  —
 D‘ ‘,5 . 

 

"...
miwordvrm » wi=  REST AP

(- 9* C‘ E https: //make. wordpress. org/ core/2015/09/21/wp-rest-api«merge«proposal/ 

31‘: 

I...
C‘

i§Vwordi= ress»i: Es'rIivi; wi,  x I

H https2/Imake. wordpress. org/ core/2015/10/28/rest-api-we| come—the-infrastruc...
Endpoints to Core WP 4.5

 lfl ” Ti“ ‘
l  ‘
l‘  ' v
E!  9 vzgji
ii ir-
ll *7:: "f"‘
ti -1" /  ‘ ‘ ‘ ‘ '

iPaciencial
Raf vvp REST API
0

lnstalacién y uso bésico
WordPress > Search for

(- C‘ [3 https ii‘wordpress. orgiplugirisiSearch. php7iypc: term&q—wardprcss+rcst+api

(V);  WORDP...
WP REST API Plugins — Ruta lnicial

Versién 1.2.x:  /wp—j son/ 

http: //www. wired. com/ wp-json/ 

Versién 2.0 Beta:  /w...
Demo

Uso bésico
Autenticacién

3 formas de autenticar

- Cookie Authentication para acceso desde plugins y temas en el servidor de
WordPre...
HTTP Basic Authentication

- Paso 1 :  Primero instalamos el plugin WP Basic Auth: 
https :  / / github .  com/ WP—API / B...
Demo Autenticacion

HTTP POST,  PUT y DELETE
«W HTTP API e WordPress c 
(- C‘ J co: ex. wordpres7s’. org/ HTTP_APi

 

  Home Page

WordPress Lessons

Helper Functions...
. / '
~g vvp REST API


O

Extensiones
.1 ,  ‘

 .1 L  ; I<* I«; iJ;4_H_I L;  }3r; _Jr-r;4j'”j

* A'n‘r= .x~: ih.  c+= .IIIl, N~? ¥= = .t ! |Il= .|.  II_I"(= .I ...
(1)
20~ active installs

WP REST API

MGHUS

(3)

400+ active installs

 

Genesis REST API Integration

Adds (ontent outp...
O podemos hacerlo nosotros mismos. ..
Nueva ruta / stats

function registra_ruta_stats( $routes ) {
$routes['/ stats'] =  array(
array( 'mis_stats',  WP_JSON_Se...
Nueva ruta / stats

mis_stats

$json_url get_json_url
$json_stats

$count_posts absint wp_count_posts publish
$count_pages...
(-

‘fill _l‘_‘' '1 " ' V:  ’: t qcil‘ ijc-i
_ pnienasapi/ wp-isonisms AMONG
C‘ ,1nruebas. api/ wp—ison/ stats <31" 9 E
{ R...
Raf WP REST API
0

El futuro de WordPress
WPrincipiante (1:

. .., ... ,.. ,,, .q. .., .

"REST API es lo mas excitante que ha
pasado en WordPress desde Ios Custom
...
Casos do Uso do WP REST API

- lntegracion con Mobile,  de verdad. 

- Separacion entre backend y frontend (a lo bestia). ...
O jacklenox/ picard-present

L

_ L‘-iil—i. li lw:  ‘J31 https: /l9ithub. com/ jacklenox/ picard-present

(- C‘

Git}-rub ...
Mi Opinion Personal

PROs

- WP REST API abre un sinfin de posibilidades nuevas. 
- Renovacion de WordPress (si,  le hacia...
lllli Opinion Personal

CONs

- Le falta madurez y consolidacion. 
- Documentacion algo escasa y no centralizada (para no ...
Recursos de interés

Documentacién

http: /Mp-q7|. orgl

http: /IlfZ. wp-api. orgl

nttpsdleewortxzreuoiiglplilglridjsorr-...
WC

TICKETS

fl HOME

i ABOUT ‘I-

:   A DAY OF REST

NEWS
9! SPONSORS
. ." HACK DAY

5'4 CONTACT

GET YOUR TICKET
Q

"‘*Q( WP REST API
0

iGracias! 

(nos vemos mafiana en el Contributor Day)

Antonio Villegas Cavillegasn
Upcoming SlideShare
Loading in …5
×

WP REST API

21,132 views

Published on

Presentación de Antonio Villegas en la WordCamp Cantabria 2015 sobre la API REST de WordPress. Definición de conceptos JSON, REST y API, historia y evolución, instalación y uso básico, extensiones, casos de uso de la API REST y posibilidades de futuro.

Published in: Internet

WP REST API

  1. 1. kgf WP REST AP! 0
  2. 2. Quién soy Ant0niO Villegas eavillegasn 9nEI_Ic1
  3. 3. ". i WP REST API C JSON + REST + API
  4. 4. JSON JavaScript Object Notation IIIDII: 3’ "title": “IHo1a, mundol", "content": "Esta es tu primera entrada. " - Esténdar - Fécilmente Legible - Soporte Universal
  5. 5. REST (Representational State Transfer) - Protocolo clientelservidor sin estado - HTTP para obtener datos o indicar Ia ejecucién de operaciones sobre Ios datos - Sintaxis universal para identificar Ios datos (UR| s) - Conjunto de acciones bien definidas
  6. 6. Acciones PEST Accién (HTTP) POST GET PUT DELETE Recurso (Objeto) / posts / posts / posts/5 / posts/5 / posts/5 Descripcién Create new Post Retrieve all Posts Retrieve Post with ID = 5 Update Post with ID = 5 Delete Post with ID = 5
  7. 7. API Application Programming Interface Una API es conjunto de funciones proporcionadas por cierto software como herramienta de desarrollo para que softwares de terceros puedan utilizar sus sen/ icios de forma externa y mas sencilla.
  8. 8. (- tit; WordPress AP| s . wows C‘ Q https: //codex. wordpress. org/ WordPress_APls Cit‘, WordPress APls The WordPress API stands for the WordPress Application Programming Interface. It can be separated into multiple API sections I topics. Each covers the functions involved in and use of a given set of functionality. Together they lonn what might be called the WordPress API. which is the pluginltheme/ add-on interface created by the entire WordPress project. - Dashboard Widgets API - Database API I HTTP API - File Header API - Fiiesystem API - Metadala API - Options API - Plugin API - Quicklags API - Rewrite API - Settings API - Shorfcode API - Theme Modification API - Theme Customization API - Transients API - Widgets API - XML—FtPC Word Press API (supersedes the legacy Blogger. Movab| eType. and metaweblog APIs) Home Page WordPress Lessons Getting Staneo working with WordPress Design and Layout Advanced Tootcs Troubleshooting Developer Docs About WordPress codex Resources Community portal Current events Recent changes Random page Help
  9. 9. WP REST API Acceso y manipulacién de contenidos desde fuera de WordPress Posts / / / / Péginas / / / / Custom Post Types Post Meta / / / / Media g/ / / / Comentarios / / / / Taxonomias / / / / Usuarios / / / /
  10. 10. tot REST API Resources i on C‘ [:1 https, ‘i/ deve| oper. wordpress. contidocslapii‘ @Developers Documentation Blog MyApps Contact REST API Resources Welcome to the REST API. Below, you'll find a full listing of all the available endpoints. As we add more endpoints, they will be automatically documented here and available through the Developer Console. Posts View and manage posts including reblogs and likes. Resource Description _ Getalist of matching posts. /sites/ $site/ posts/ Get a single post (by ID). / sttes/ $site/ posts/ $post_| D Authentication Users Sites Posts Comments Taxonomy Follow Freshly Pressed
  11. 11. FE fir l~I‘l; i‘(ci‘ , -.l. ... .l Uri w: :i»jic-I»: C'_l;4
  12. 12. tfi XML RPC womprr, -ss A (- C‘ Q huos coaex. wordpiess. org xv «- . w 1-‘v-~ ‘ Aw 5 Ci‘; WORDPRESSORC; Showcase Themes Pluglns Mobile Getlnvolved About Blog Hosting Dommloadwordfiress Codex Cont: mir. .0; lfl XML-RPC WordPress API umwaqo Ws. ‘lt: F"eS> Lessons XML-RPC ADI (rat supe'secas the legacy Bioggez N'ovaoleType ano melawsblog APls Some r: wants also 9XISl lor d<‘levenl CE“ 4: gym crogvammirg larguages wcmnq mm . vuuPves: . Compongnts nwqr aw‘ . avoifl - ems (lor posls pages and custom po51type5l~ Added m Wo'<. "ies: ; 3 4 Awmr-*2 T09 E5 - wu 999031 Yrcu: )les"c<: Mc - el= osls W 9 Dmelaaer Docs - wp r‘awPas| _ W9 edlypofl Amu ': '/Cv: :P'€SS - v. u Geleleposl - wp get= osITyoe Codex Resources - mo gel= osvTyoes C{>rr'ni. n‘ypnr'al - we get= osiFovmats - wp gel= ’oslSlalusLisl Omen‘ e4en‘s
  13. 13. (- ~_u, l twovavmss»Jsowtrl-i - C _“ httos/ /wordpress.0r9/Dlt. girs. l_son—apl/ JSON API Dnpitlrlr ; aV(W? (=< 5% WSW A R1-3Tful API for WordPress I1-, v -. . Ocvclopc“: Desciioiio-i is-. <il. iit. Sl'HE7t'l‘Jl~' Ot"i-rN)(-:5 th. ii. ;—lci: Sta'> siioooi: we~nev. s Us-ve‘JL7{-'5 search Pluglns Search Popular Tags : /ldgetij 9/ : ' 5i: ‘;<i ~lC-ICE! lg llJi : l’QV': DCE- 2 333 iztialaleil 11935] JSON API allows you to retrieve and manipulate WordF’ress content using HTTP requests, There are three main goals: 1 Provode a simple, consistent external interface 2. Create a stable, understandable internal implementation 3. Enable new types of extensions lor WordPress This pliigin was created at the rt-useum at T'Odt‘l'l Air lor the weblog li-s do/ out which is served Viom Ruby on Rails. Instead oi reimplernenting the site templates as a WordPress theme, we opted for a Rails rront-end that displays (clntent served from a WordPress batk end. JSON API provides the necessary interface for retrieving content and accepting comment submissions See the other Notes section forthe complete documentation tags: d(ll“ll , Al; -)c cJl, (ill), ll'. €}: 'd', lCll isum ‘- ui-ta Requires: 2.3 or hignei Compatible up to: 4.3.! Last Updated: 2 months ago Alrtive Installs: 30,00lJ¢ Ratings 4.8 out of 5 stars 1 stars 57 astars 4 Astars l 2 stars l l stai l Author A do-i ttnr ° 3 plu, -;l‘5 ul= .lIlll= lIl: .
  14. 14. JSON REST API Ryan Mccue o-gnunuon: wawmu Anlunod nmnnn: Brynn Pony Alanna: Al -no momml ma only ma API In aa: cuwP mm: um um xnnvc API, rm mum n Vull mm u’ wanna ms and 1 man man ooumal '0' mos! mos In use van. XML wane lsmavy win mu-nu ms causaa pvwems on meals nlnflovms, mm re the man eovvmrmn of no API A JSON REST AF! rovmvm mud: M mm comvlaxury by usm a umoiv sevmsamn ‘arms: IJSON) mm: a owloeu wanna by most 94 me no va uannam HTYP vows‘ Azmcmomml‘ Ineonryroa1AP| IoacoessWPmnxm: s:mXM. -RPCAPI Tm: roqwosflul mmotpasangznmsau u was man om-nu kw mu! an | n IM pan. XML mm (usuully mm nuxmu has coma orulums M mooilu om-cam. mm are ‘he mum eon-mmov-. v-em. A JSON RESTAPI mmovou mum um-oomowmty by using a name: uonsanorl ‘ormal 1150») mm a relax»! mm 01 was: a me woo vn mac Hrw vem CODE SAMPLES Filo namo Sin um Iuhvnmnd lynn_I: cut. gx October on zuu moo um
  15. 15. (- J . 1:4} all J all i It V Woraflrou . JSON REST _ C‘ ‘i nttps: /tmake. wordpress. org/ core/2013/06/17/, son-rest—api/ _l( I‘ Make WordPress Core Blog Handbook Ryan MCCUEII U127‘ ori. iurit- ti (A V: Tau! ‘ (_: socl78 . gs£x2L‘3 ii: L isoi api i .1: JSON REST API Hi everybody! some ol you may know me lrom various patches or WP—re| ated endeavours‘ I'm Ryan Mccue. developer 01 the Sir'ip‘ePte library used in core. along with a HTTP library called Reqi. es'. s. and long-time core hacker. I've been working with WordPress tor quite a while now. both on open source and protessional work with clients What you may not know is that I'm also studying Electncal Engineering and Maths at U0 in Australia. and I‘m here to give you a heads up on my Summer or Code proiect over the coming months ‘est-2|: _ ‘ For those who missed the discussion on wpetiackers about my proposal. I'm working on a . lSON—t>ased REST API tor core I started on this with an initial proot-ot~concapt back at the end at last year, and I'm now working on expanding this out Into a iaigei project The code IS Doing wntteri as a pluglfl tor testing. with the goal 0! having it integrated into core in some torm post-GSOC. I‘m planning on ioiiowing a release strategy simiiar to MP6. with a weekly release along wlth the updates included in the retease. At the moment, I'm working on coi“p‘etirig the be: c reedmg and M: ii; 0' pos: data having just completed the me, or design documents. and I'm hoping to get the first weekly release out next week. I have a more detailed timelirie which you can check out in my anroiincement post on my blog (You'll notice I'm currently about a week behind on my schedule. which I suspected may happen, as I‘m in the midst at my tinal exams here, I've allocated an extra week ]U5t betpre the midsemester review tor catching up it I don't do so betole then I As it is. the plugin is in a usable tomiat, and you can grab it trom either GIKHLD or Suovers on. I'd also recommend checking out the (5500 ‘vac ’%tit= sIIyou'I1|Iketo keep track 0| the status I'd love to have your feedback (especially on the oesign documents) as I move lprward Cheers. and I look lorward to working with you all in the coming months‘ Tickets Components 097 Welcome to Make WordPress Core! T» . ’tl‘i‘I" i '31] t. —-i». - ON‘ Y “'t‘ '0 FY »'in»v. nw. pm~ nrier r. i~i. i~niwi. ..~ rn Wu, my why. , mm: ii rai", ~ryiS<1i l"("". ' mi win rtnn i‘r> I‘ Tu; e lL' {.7 get 'l~. /“. L‘d Check out um curt‘/ it)uto' mnaboaii lLuYu Search Email Updates Y“? ,-—i Sign me up: [Ir 0]: QIIIC‘.
  16. 16. A J . Meet the Te m ,5_~_{v(¢-r. 2:’ 7 W 1
  17. 17. Versiones - Version 0.1 (Junio 2013) - Version 0.1.1 (Junio 2013) a Version 0.9 (Abril 2014) - Version 0.6 — GSoC Final (Septiembre 2013) - Version 1.0: Users, revisions, meta, plus many more (Mayo 2014). - Version 1.1: Better taxonomies, bunch o’ bug fixes, and test coverage (Junio 2014). - Version 1.2: CORS support, request hijacking, better errors, and a swarm of bug fixes (Marzo 2015). - Version 1.2.1: Security Release (Abril 2015). - Version 1.2.2: Security Release (Mayo 2015). - Version 1.2.3: Security Release (Agosto 2015). - Version 2.0 Beta 1 “Ralph Wiggum” (Abril 2015). - Version 2.0 Beta 1.1 “Ca| | in a Code 8”: Security Release (Mayo 2015). - Version 2.0 Beta 2 “You Finally Made a Monkey Out of Me” (Mayo 2015). - Version 2.0 Beta 3 “Disco Stu Doesn’t Advertise” (Julio 2015). - Version 2.0 Beta 4 “See My Vest” (Agosto 2015). - Version 2.0 Beta 5 “Ay, caramba! ” (Octubre 2015).
  18. 18. La Pregunta. .. ; F~. : ; ; ill ii ] l . . it , T 1‘! H‘-'5 3 1 If ‘T: ll ‘ I ! ‘ s u -. ._ ll w — D‘ ‘,5 . "‘I w. 3 A z, Cuando tendremos WP REST API en el Core de WordPress?
  19. 19. miwordvrm » wi= REST AP (- 9* C‘ E https: //make. wordpress. org/ core/2015/09/21/wp-rest-api«merge«proposal/ 31‘: I Make Word Press Core sf Ryan Mccue 3:03 am on sepmnoar 21, mi 5 Tags: reaiiira piugins l 45 J. )SOFl-apt ( 25 ). merge 1 io ). proposal l 1-5 i. rest-apt i 27) WP REST API: Merge Proposal Hello everyone! This is the post you've all been waiting for. ;- This is our first iteration of the proposal, and we’re actwely looking lor feedback. If you have thoughts on the project. or on this proposal, let us know! Only with your feedback can we make progress. -4 What's the plan? The plan we're aiming for is a two part merge of the API. For the first stage, the infrastructure code would be merged into wp-includes and made available for plugins and themes. This is an intemal API only, but offers an "API construction kit” lor developers to use. For the second stage, the endpoints would be merged, and the API would be enabled for sites by default. This plan splits the API into two pans, infrastructure and endpoints: - Stage One: Infrastructure: The infrastructure is the code responsible lor routing requests and handling the "meta" layer of the API, including JSON serialisatiori/ deserialisation, linking, embedding, and REST best practices. This adds a simplified routing layer outside of WP‘s rewrites, allowing non-query-var rewrites easily, acting as a base for building APls inside WordPress. Stage Two: Endpoints: These are where much oi the complexity of the API lia. as they're responsible for mapping data from the extemal JSON lormat to the intemal data stmctura, and vice versa. The "business” logic of integrating with WordPress is almost entirely contained within the endpoints. These are the more complex part of the API. as they require using deep APIs in WordPress, and handling security and privacy concerns. Blog Handbook Tickets Components 007 Welcome to Make WordPress Core! This is the official blog for the core development team of the WordPress open source project. Follow our progress with weekly meeting agendas. project schedules, and the occasional code debate | fyou‘d like to get involved with core, check out our coritnbutor handbook Email Updates SUDSCVID8 to lhis blag and receive naiiications of new posts by email Joiri 5,404 other suhscribefi Email Acdress Sign me up!
  20. 20. C‘ i§Vwordi= ress»i: Es'rIivi; wi, x I H https2/Imake. wordpress. org/ core/2015/10/28/rest-api-we| come—the-infrastructure-to-core/ ii? / ' Make Word Press Core ? ‘ Ryan Mccue 7:30 am on October 28, 2015 rags. 4 4 i 35 J. dewnotes 4 too I. l5DVV~apl i 27 i. resrapi l 29) REST API: Welcome the Infrastructure to Core Hi from the REST API team! We're extremely excited to announce the API infrastructure has now been merged into core as of r3492B (plus a couple of fix up commits we won’t mention). Huzzahl Sincere thanks to every single one of the contributors. we wouldn't be where we are today without you. It takes time and effort to produce great things, and it's impossible to make things great without everyone helping. This has been a tmly collaborative effort, and I wish I could do more than just give you props. [Important note: if you have a 2.0 beta already installed. you must upgrade to beta 5.) What's included in 4.4? As mentioned in the merge proposal, the API comes in two parts: infrastructure and endpoints. In 4.4. the infrastructure is now available as part of core, while the endpoints continue to only be available in the plugin. You can think of the infrastructure as an "API constmction kit". WordPress 4.4 will make it possible for everyone to build RESTni| APIs in a much easier fashion, which will benefit people building custom APIs for their site. The infrastructure handles the routing, argument handling. JSON serialisation/ deserialisation, status codes, and all that other lovely REST stuff. For client authors, this doesn't help you much right now. Hold tight. the team is working as fast as we can on the endpoints to get them ready for a future release. In the meantime. you can make sure sites you want to work with have the plugin installed, which isn't a change from the current state. For plugin and theme authors, you can start building new APls immediately using the infrastructure now in core. This can start relacin our existin custom adllin-u ‘ax end ints or other bes ke code ou alread Blog Handbook Tickets Components cor Welcome to Make WordPress Core! This is the official blog for the core development team of the WordPress open source project Follow our progress with weekly meeting agendas. project schedules, and the occasional code debate | lyou‘d like to get involved with core, check out our contributor handbook Email Updates Subscribe to ll'lS blog and receive r‘OIlfiC: .t! l(1r‘S of new posts by email Join 5,404 other subscribers Ell‘3ll Accress Sign me up!
  21. 21. Endpoints to Core WP 4.5 lfl ” Ti“ ‘ l ‘ l‘ ' v E! 9 vzgji ii ir- ll *7:: "f"‘ ti -1" / ‘ ‘ ‘ ‘ ' iPaciencial
  22. 22. Raf vvp REST API 0 lnstalacién y uso bésico
  23. 23. WordPress > Search for (- C‘ [3 https ii‘wordpress. orgiplugirisiSearch. php7iypc: term&q—wardprcss+rcst+api (V); WORDPRESSORC Showcase Themes Mobile Plugin Directory Search Results ream etl i‘ooulai Hm: i: -as Beta Wasting WordPress REST API (Version 2) Access your sites data through an easy—ta— use HTTP REST AM. (Version 2) By Ryan Mrtiue Rachel Baker, DOrVi‘€/ Bachhube r, and /02 Hoyle (9) Last Updated: 6 days ago 2,003» SUI‘. /E installs Compatible up to: 4 4—beta Support Get Involved About Blog Hosting Username {Z7} 1 1000- active installs Password Keyword v Q Download WordPress Lat; ll‘ (forgo? ) or Reg star wordpress rest ap WP REST API (WP API) Acress your sites data through an easy—to— use Hlll’ REST API. By‘ Ryan M((ue and Paths! Baker. Last Updated: 3 months ago Compatible up to: 4.: l—alpha
  24. 24. WP REST API Plugins — Ruta lnicial Versién 1.2.x: /wp—j son/ http: //www. wired. com/ wp-json/ Versién 2.0 Beta: /wp-json/ wp/ v2/ http: //demo. wp-api. org/ wp-json/ wp/ v2/
  25. 25. Demo Uso bésico
  26. 26. Autenticacién 3 formas de autenticar - Cookie Authentication para acceso desde plugins y temas en el servidor de WordPress - OAuth 1.0 para acceso desde el exterior (clientes web / mobile apps/ aplicaciones de escritorio) - H1'l'P Basic Authentication para pruebas, nunca en produccion
  27. 27. HTTP Basic Authentication - Paso 1 : Primero instalamos el plugin WP Basic Auth: https : / / github . com/ WP—API / Bas1c-Auth - Paso 2: Autenticamos pasando un header HTTP como este: Authorization: Basic ! WRt-. aW46cGFxc3dvcmQ- que no es mas que admin: password codificado en Base64
  28. 28. Demo Autenticacion HTTP POST, PUT y DELETE
  29. 29. «W HTTP API e WordPress c (- C‘ J co: ex. wordpres7s’. org/ HTTP_APi Home Page WordPress Lessons Helper Functions The helper iunclions utilize the HTTP API classes to simplify the process as much as possible. Vou could use the classes and could Getting started use some at the methods to help process the code. The classes assume that you know what you are doing and can use the classes. womng Mm wmdpress Design and Layout You must use the helper tunctlons ll you are modifying the core code of WordPress. It is one ol the reasons lor the helper API. to reduce the amount of error checking and prevent having to edit multiple places when bugs are lound. Advanced TODlC5 Troubleshooting The lunctions below are the ones you will use to retrieve an URL. Please be aware that these functions will return a WordPress De‘/ eiope, Docs WP_Error class on iailure. You will have to check lor that alter using these iunctions. About WordPress wp, rerrote, get() - Retrieves a uRL using the GET HTTP methoo. wp_rerrote_post() - Retrieves a URL using the POST HTTP method. codex Resources wp_r'crrote_hcad() - Retrieves a URL using the HEAD HTTP method. wp_rerrote_request() - Retrieves a URL using either the default GET or a custom HTTP method (should be caps) that you speciFy. Community portal Current events Recent changes The other helper lunctions deal with retrieving dilterient parts of the response and do me testing lor WP_Errcr lor you, mese make R d 31'! cm 3 8 usage 01 the API very simple and are the preterred method lor processing response obiecm. D Q Help v. p_renote_retrieve_t>acy() - Retrieves just the body troiri the response. up_rerrote_retrmve_heauer() - Gives you a single HTTP header based on name train the response. wp_rErrote_re(riEve_heai1ei‘S() - Returns all of the HTTP headers in an array tor processing. vp_runote_retrieve_responsc_touer) - cites you the number tor the HTTP response. This should be zoo, but toutu be 4xx or even Jxx on failure. - up, rerrotegreti-ieve_response_nessage() - Returns the response message based on the response code.
  30. 30. . / ' ~g vvp REST API O Extensiones
  31. 31. .1 , ‘ .1 L ; I<* I«; iJ;4_H_I L; }3r; _Jr-r;4j'”j * A'n‘r= .x~: ih. c+= .IIIl, N~? ¥= = .t ! |Il= .|. II_I"(= .I fv)Zfl; i'(f-! Il"(fv* ‘ Cil: +=. lr uu= w=. ne lI_i't= .h‘» % [x: ;.~+: xcaiv: :u llI't. =.! s‘» : ):fl; i‘(: :n‘(: »:= w= _u. |?: n=_: « , ox: mnfl: m:N oil? -4 = _Lo~ro{¢.1.é1q> : _I. II_I"t= _t: ;
  32. 32. (1) 20~ active installs WP REST API MGHUS (3) 400+ active installs Genesis REST API Integration Adds (ontent output from the Genesis framework hooks to the response data for posts, pages. and custom post types when using the WP REST APl v2. By: Broad. Last Updated: 2 months ago Compatible up to: 4.3.1 WP API Menus Extends WordPress WP REST API with new routes pointing to WordPress menus. By: Fulvia Notarste/ ano. Last Updated: 2 weeks ago Cc (1) 80- active installs 171 downloads WPML to WP API By: ryuheixys, (U 100+ active installs WP API Customizer Make post meta data (custom field values) available for]SON REST API (WP API) when unauthenticated. By: Kite. Last Updated: 10 months ago Compatible up to: 4.1.8 WP REST API Multisite Very simple wordpress plugin who add the posibility to list all sites in WP REST API. Q/ : the_glu. Last Updated: 6 months ago Compatible up 10:42.5 Allows you to request a language with your WP-API and WPML site. Last Updated: 6 months ago Compatible up to: 4.2.5
  33. 33. O podemos hacerlo nosotros mismos. ..
  34. 34. Nueva ruta / stats function registra_ruta_stats( $routes ) { $routes['/ stats'] = array( array( 'mis_stats', WP_JSON_Server: :READABLE ), )7 return $routes; } add_fi1ter( 'json_endpoints', 'registra_ruta_stats'
  35. 35. Nueva ruta / stats mis_stats $json_url get_json_url $json_stats $count_posts absint wp_count_posts publish $count_pages absint wp_count_posts publish $count_comments wp_count_comments total_comments $count_users count_users $count_tags absint wp_count_terms $count_categories absint wp_count_terms $json_stats $count_posts $json_stats $count_pages $json_stats $count_comments $json_stats $count_users $json_stats $count_tags $json_stats $count_categories $json_stats $json_url $json_stats
  36. 36. (- ‘fill _l‘_‘' '1 " ' V: ’: t qcil‘ ijc-i _ pnienasapi/ wp-isonisms AMONG C‘ ,1nruebas. api/ wp—ison/ stats <31" 9 E { Ravv Parsed "posts": 19, "pages": 5, "comments": 121, "users": 2, "tags": 0, "categories": 1, "meta": { "links": { "self": "http: //pruebas. api/ wp—json/ stats/ ” } } } ml-It: 3H3llI]_IllOl~‘ mi iIiIi§: ):1- *3;-; .:. ’. . ,p3.. i'. .., i*. ._. i.; .., ;.. ;i, ,;. ;.. _
  37. 37. Raf WP REST API 0 El futuro de WordPress
  38. 38. WPrincipiante (1: . .., ... ,.. ,,, .q. .., . "REST API es lo mas excitante que ha pasado en WordPress desde Ios Custom Post Types" ricardpriet en wprincipiante. es/ ricardo-prieto. . , rt‘ ‘L’ ‘ If , l , ,T= ',", “E' / , . V - . I [,1 gi 2 ’ '/ . ‘. ‘,r, . i’ ; i V ~. ii , / 4' , ‘ (xx 1 ‘N on "' K’ « . . “ H I . . ’-»A> ai‘ Ricardo Prleto - El WProfaslonal del Mas Siguiendo Ia saris de entrevistas a profesionales de WordPress, el WProfesional del Mas es Ricardo Prieto, desde Sevilla.
  39. 39. Casos do Uso do WP REST API - lntegracion con Mobile, de verdad. - Separacion entre backend y frontend (a lo bestia). - Paneles de control focalizados. - Mashups sin usar Web Scrapping. - SPA (Single Page Application). - Temas més interactivos y ligeros. Y muchas opciones mas aun por explorar. ..
  40. 40. O jacklenox/ picard-present L _ L‘-iil—i. li lw: ‘J31 https: /l9ithub. com/ jacklenox/ picard-present (- C‘ Git}-rub Explore Features Enterprise Pricing jacklenox / picard-present owaxcn 24 A presentation theme that uses the REST API Picard Present Picard Present is a prototype WordPress theme that makes use of React and the new WP—APl which, at some point, will be going into WordPress core, Getting Started If you want to start developing with this theme, you'll need to: Clone this repo to your computer (e. g. git clone git@github. cam/ jacklenox/ picard-present. git) Run npm install to install the node dependencies Run gulp js to compile the Javascript Set your permlinks to / %year%/ %monthnum%/ %day%/ %postname%/ and if required clear your Iocalstorage. PF-’! ’. " Sign In tstar 123 3?Fork I5 0 Code ' issues l I'I Pu l requests 9 4» Pu'se . |i Graphs HTTPS clone URL httpsl/ /gith| .lb. (Oli E4 You can Cl07‘iS with HWPS or Subversion ii) iii clone in Desktop 4) Download ZIP
  41. 41. Mi Opinion Personal PROs - WP REST API abre un sinfin de posibilidades nuevas. - Renovacion de WordPress (si, le hacia falta). - Menos PHP y mas Javascript. i
  42. 42. lllli Opinion Personal CONs - Le falta madurez y consolidacion. - Documentacion algo escasa y no centralizada (para no techies). - , ',Demasiada Iibertad en el desarrollo de temas? $0” —= -= iua'**’ _. r’'_'. . s—. T
  43. 43. Recursos de interés Documentacién http: /Mp-q7|. orgl http: /IlfZ. wp-api. orgl nttpsdleewortxzreuoiiglplilglridjsorr-rest-apll nttpsdllrrordpresaorg/ pluginslrest-apll imp: /Moapl. orgIguldssIgetllng-s1aned. l1trnI iit1ps1Irriake. wordpress. org/ oore: '201 5/08/25/siiow-nle-yoiir-V4‘: -rem-aplaie-apps/ nttpsJhnake. mmpress. org/ wref2015I09/21Mp-ms! -aptnierge-pruposav iittpsJlgi1tiub. oomIpetanelsoriIextendlng-w; Hes1-apl Arliculos iittps-J/ idrista. oom/ biog/ luordpress-rest-apl—baslcsI httpsvmristaoommoglguhe-b-mu)-and-me-worfixessimp-api-pan-1/ httpsvndristaoommloglgufleb-mlp-arid-me-wortxxess+mp-apkpan-21 littpJMww. sitepolnLoorriMp-apll littpJlpremIum. wpmudev. orgIblogIworthtese-rest-apil httpJIspin. aI>mu: ob| a¢n. oonv2015I09I15Mp-epl-wordpiess-web-app! littpJlwptavem. oorn/ iagiwordprewnam-apl littpJIoctuweh. oomIiest-apt-futuro-ttiemeeworibrew Slides & Videos iittps: Ilspeakerdedt. oornIrrnocueIwcrryca014 nttpsdlspeakerdedcoomlraoiiebakemltilizhg-the-w; >ros1-apl Imps Jlspeakardeckoomhadiebakerlpm-your-comem-to-rest-vntii-wpyapl iittpdlliirordprssalv/201 5/0711 1lryan—rnowe-the-wordprewrost-apfizl iitip: /Iluordpresatv/201 slosfzslpetermeisorreidendirig-trio-wpaest-apkbeymd-me-basics! nttpzllluordpresalv/ imlwp-rest-apt! Temas imp: /lbulldlngtherne%restapl. oornI iit1psJlgi1tiub. oon1IAinormttlc/ Picard rit1ps1lgi1tiub. oornI| acklerox/ plcard-preeem nnpJnhevnesl1aper. wniI2D15I05I07mwm| rig-Mnrflieaestepbnieebpbardl nnpdMmavem. omn4ack4erox-on«biiiHing-v'ieneo-Mflrflio-wprem-apl Auienticacion http1Mp-apI. org/ guldesIautl1ent| catlon. htrrl littps-J/ tlmnash. co. ukMordpress-rest-apl-authentlcatlon-exaniples/ mipsr/ giinui: .oom/ vrP-Aeusasic-Auin https1lgl1hub. oom/ WP—APlIOAmiI1 lntegraciones http: /Moo1hernes. gitiIub. ioMoooorrimerceIrest-apl iittpsJlgi‘itiub. oomIirodemlooperlbirddypreu-[son-ant iIttps1Igi‘ihub. oomIihenbroni/ BB-API iittpsdlgittiubcomlpods-frarneworldpocls-| son—apl Otros https'l/ www. getpos1man. corrII https1Igl1i1ub. oomIcaIlumlocke/ ison-i‘onnaner https'JIoode)cwordpiess. orgll-lTl'P_API http1IteelIngresflti| .ooml http1lwww. wired. oorn/ wp-| son/ http1Ipos1status. i:ornMp-ison https-JIcamabrLa. wordcarrip. orgIz01 5/wp-(son/
  44. 44. WC TICKETS fl HOME i ABOUT ‘I- : A DAY OF REST NEWS 9! SPONSORS . ." HACK DAY 5'4 CONTACT GET YOUR TICKET
  45. 45. Q "‘*Q( WP REST API 0 iGracias! (nos vemos mafiana en el Contributor Day) Antonio Villegas Cavillegasn

×