Your SlideShare is downloading. ×
Build a Restfull app using drupal
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Build a Restfull app using drupal

249

Published on

Presentation about how to build an API for your drupal CMS

Presentation about how to build an API for your drupal CMS

Published in: Internet, Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
249
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MAY 29 & 30, 2014 Barcelona @alvar0hurtad0 Drupal’s API
  • 2. SO
  • 3. SO
  • 4. SO
  • 5. SO +18
  • 6. W
  • 7. T
  • 8. Drupal sites Dries Buytaert March 2012
  • 9. ~7% CMS SITES Dries Buytaert March 2012
  • 10. 30% WEB SITES Dries Buytaert March 2012
  • 11. launch top deprecated
  • 12. T launch top deprecated
  • 13. T launch top deprecated
  • 14. T launch top deprecated
  • 15. 30% WEB SITES Dries Buytaert March 2012
  • 16. Dries Buytaert March 2012
  • 17. 7 8
  • 18. 7 8 IM
  • 19. 7 8 IM • MULTILINGUAL • UX/ADMINISTRATION EXPERIENCE • MOBILE FRIENDLY • CONFIGURATION MANAGEMENT • WEB SERVICES
  • 20. Photo: Carlos Francisco Peña
  • 21. Photo: Carlos Francisco Peña D
  • 22. Photo: Carlos Francisco Peña D • LAYOUT CLICK BY CLICK • DATA MODEL CLICK BY CLICK • DATABASE QUERYS CLICK BY CLICK • TRIGGERS AND ACTIONS … • USER PERMISSIONS … • WEB SERVICES CLICK BY CLICK
  • 23. Photo: Carlos Francisco Peña DATA MODEL
  • 24. Photo: Carlos Francisco Peña DATA MODEL
  • 25. Photo: Carlos Francisco Peña DATA MODEL
  • 26. Photo: Carlos Francisco Peña DATA MODEL 
 CONTENT MODELING • CONTENT TYPES • COMMENTS • USER PROFILES • COMMERCE PRODUCTS • ….
  • 27. DATABASE QUERYS CLICK BY CLICK
  • 28. DATABASE QUERYS CLICK BY CLICK
  • 29. DATABASE QUERYS CLICK BY CLICK
  • 30. DATABASE QUERYS CLICK BY CLICK
  • 31. DATABASE QUERYS CLICK BY CLICK
  • 32. USER PERMISSION CLICK BY CLICK
  • 33. USER PERMISSION CLICK BY CLICK
  • 34. USER PERMISSION CLICK BY CLICK
  • 35. USER PERMISSION CLICK BY CLICK
  • 36. REST SERVICES CLICK BY CLICK
  • 37. REST SERVICES CLICK BY CLICK
  • 38. REST SERVICES CLICK BY CLICK
  • 39. SERVICES AUTHENTICATION
  • 40. SERVICES AUTHENTICATION IN CORE • HTTP basic authentication • Cookie
  • 41. SERVICES AUTHENTICATION IN CORE • HTTP basic authentication • Cookie CONTRIBUTED MODULE • Oauth
  • 42. SHOW ME THE CODE
  • 43. SHOW ME THE CODE 
 CURL curl -H "Accept: application/hal+json" --request GET http://drupal-8.localhost/node/1
  • 44. SHOW ME THE CODE 
 CURL curl -H "Accept: application/hal+json" --request GET http://drupal-8.localhost/node/1 
 Guzzle <?php use GuzzleHttpClient; $client = new Client('http://drupal-8.localhost'); // If in a Drupal environment use the HTTP client service. $client = Drupal::httpClient()->setBaseUrl('http://drupal-8.localhost'); $request = $client->get('node/1'); $request->addHeader('Accept', 'application/hal+json'); $response = $request->send()->json(); print_r($response); ?>
  • 45. SHOW ME THE CODE 
 CURL curl -H "Accept: application/hal+json" --request GET http://drupal-8.localhost/node/1 
 Guzzle <?php use GuzzleHttpClient; $client = new Client('http://drupal-8.localhost'); // If in a Drupal environment use the HTTP client service. $client = Drupal::httpClient()->setBaseUrl('http://drupal-8.localhost'); $request = $client->get('node/1'); $request->addHeader('Accept', 'application/hal+json'); $response = $request->send()->json(); print_r($response); ?> 
 CURL curl --include --request POST --user cleverFucker:secret --header 'Content-type: application/hal+json' http:// drupal-8.localhost/entity/node --data-binary '{"_links":{"type":{"href":"http:// drupal-8.localhost/rest/type/node/page"}}, "title": [{"value":"APIdaysBNC"}]}'
  • 46. SHOW ME THE CODE 
 CURL curl -H "Accept: application/hal+json" --request GET http://drupal-8.localhost/node/1 
 Guzzle <?php use GuzzleHttpClient; $client = new Client('http://drupal-8.localhost'); // If in a Drupal environment use the HTTP client service. $client = Drupal::httpClient()->setBaseUrl('http://drupal-8.localhost'); $request = $client->get('node/1'); $request->addHeader('Accept', 'application/hal+json'); $response = $request->send()->json(); print_r($response); ?> 
 CURL curl --include --request POST --user cleverFucker:secret --header 'Content-type: application/hal+json' http:// drupal-8.localhost/entity/node --data-binary '{"_links":{"type":{"href":"http:// drupal-8.localhost/rest/type/node/page"}}, "title": [{"value":"APIdaysBNC"}]}' 
 Guzzle (I) <?php use GuzzleHttpClient; $client = new Client('http://drupal-8.localhost'); $client = Drupal::httpClient()->setBaseUrl('http://drupal-8.localhost'); $node = array( '_links' => array( 'type' => array( 'href' => 'http://drupal-8.localhost/rest/type/node/page' ) ), 'title' => array(0 => array('value' => 'New node title')), );
  • 47. SHOW ME THE CODE 
 CURL curl -H "Accept: application/hal+json" --request GET http://drupal-8.localhost/node/1 
 Guzzle <?php use GuzzleHttpClient; $client = new Client('http://drupal-8.localhost'); // If in a Drupal environment use the HTTP client service. $client = Drupal::httpClient()->setBaseUrl('http://drupal-8.localhost'); $request = $client->get('node/1'); $request->addHeader('Accept', 'application/hal+json'); $response = $request->send()->json(); print_r($response); ?> 
 CURL curl --include --request POST --user cleverFucker:secret --header 'Content-type: application/hal+json' http:// drupal-8.localhost/entity/node --data-binary '{"_links":{"type":{"href":"http:// drupal-8.localhost/rest/type/node/page"}}, "title": [{"value":"APIdaysBNC"}]}' 
 Guzzle (I) <?php use GuzzleHttpClient; $client = new Client('http://drupal-8.localhost'); $client = Drupal::httpClient()->setBaseUrl('http://drupal-8.localhost'); $node = array( '_links' => array( 'type' => array( 'href' => 'http://drupal-8.localhost/rest/type/node/page' ) ), 'title' => array(0 => array('value' => 'New node title')), ); 
 Guzzle (II) $data = json_encode($node); $response = $client->post('entity/node', array( 'Content-type' => 'application/hal+json', ), $data) // Username and password for HTTP Basic Authentication. ->setAuth('klausi', 'secret') ->send(); if ($response->getStatusCode() == 201) { print 'Node creation successful!'; } ?>
  • 48. SOAP?
  • 49. SOAP?
  • 50. SOAP?
  • 51. QUESTIONS !!! ?¿? !!! I’ve a question
  • 52. ONE MORE THING
  • 53. THANKS Alvaro J. HurtadoVillegas www.twitter.com/aspgems www.twitter.com/alvar0hurtad0

×