SlideShare uma empresa Scribd logo
1 de 59
Baixar para ler offline
MAY 29 & 30, 2014
Barcelona
@alvar0hurtad0
Drupal’s API
SO
SO
SO
SO +18
W
T
Drupal sites
Dries Buytaert March 2012
~7%
CMS SITES
Dries Buytaert March 2012
30%
WEB SITES
Dries Buytaert March 2012
launch
top
deprecated
T
launch
top
deprecated
T
launch
top
deprecated
T
launch
top
deprecated
30%
WEB SITES
Dries Buytaert March 2012
Dries Buytaert March 2012
7 8
7 8
IM
7 8
IM
• MULTILINGUAL
• UX/ADMINISTRATION EXPERIENCE
• MOBILE FRIENDLY
• CONFIGURATION MANAGEMENT
• WEB SERVICES
Photo: Carlos Francisco Peña
Photo: Carlos Francisco Peña
D
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
Photo: Carlos Francisco Peña
DATA MODEL
Photo: Carlos Francisco Peña
DATA MODEL
Photo: Carlos Francisco Peña
DATA MODEL
Photo: Carlos Francisco Peña
DATA MODEL


CONTENT MODELING
• CONTENT TYPES
• COMMENTS
• USER PROFILES
• COMMERCE PRODUCTS
• ….
DATABASE QUERYS CLICK BY CLICK
DATABASE QUERYS CLICK BY CLICK
DATABASE QUERYS CLICK BY CLICK
DATABASE QUERYS CLICK BY CLICK
DATABASE QUERYS CLICK BY CLICK
USER PERMISSION CLICK BY CLICK
USER PERMISSION CLICK BY CLICK
USER PERMISSION CLICK BY CLICK
USER PERMISSION CLICK BY CLICK
REST SERVICES CLICK BY CLICK
REST SERVICES CLICK BY CLICK
REST SERVICES CLICK BY CLICK
SERVICES AUTHENTICATION
SERVICES AUTHENTICATION
IN CORE
• HTTP basic authentication
• Cookie
SERVICES AUTHENTICATION
IN CORE
• HTTP basic authentication
• Cookie
CONTRIBUTED MODULE
• Oauth
SHOW ME THE CODE
SHOW ME THE CODE


CURL
curl -H "Accept: application/hal+json" --request GET
http://drupal-8.localhost/node/1
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);
?>
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"}]}'
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')),
);
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!';
}
?>
SOAP?
SOAP?
SOAP?
QUESTIONS !!! ?¿? !!!
I’ve a question
ONE MORE
THING
THANKS
Alvaro J. HurtadoVillegas	

www.twitter.com/aspgems	

www.twitter.com/alvar0hurtad0

Mais conteúdo relacionado

Destaque

Destaque (11)

Patent wars, Innovation, Roads
Patent wars, Innovation, RoadsPatent wars, Innovation, Roads
Patent wars, Innovation, Roads
 
APIfying the Web with import.io (at APIdays mediterranea)
APIfying the Web with import.io (at APIdays mediterranea)APIfying the Web with import.io (at APIdays mediterranea)
APIfying the Web with import.io (at APIdays mediterranea)
 
I want to be an efficient developer - APIdays Barcelona version
I want to be an efficient developer - APIdays Barcelona versionI want to be an efficient developer - APIdays Barcelona version
I want to be an efficient developer - APIdays Barcelona version
 
usable rest apis, by Javier Ramirez from teowaki (Apidays Mediterranea)
usable rest apis, by Javier Ramirez from teowaki (Apidays Mediterranea)usable rest apis, by Javier Ramirez from teowaki (Apidays Mediterranea)
usable rest apis, by Javier Ramirez from teowaki (Apidays Mediterranea)
 
Enhance the browser_experience
Enhance the browser_experienceEnhance the browser_experience
Enhance the browser_experience
 
Api barcelona
Api barcelonaApi barcelona
Api barcelona
 
AIL Platform APIDays Mediterranea
AIL Platform APIDays MediterraneaAIL Platform APIDays Mediterranea
AIL Platform APIDays Mediterranea
 
The importance of /me
The importance of /meThe importance of /me
The importance of /me
 
Battelfield REST, API Development from the trenches
Battelfield REST, API Development from the trenchesBattelfield REST, API Development from the trenches
Battelfield REST, API Development from the trenches
 
Gov APIs: The Notorious Case of Official Statistics
Gov APIs: The Notorious Case of Official StatisticsGov APIs: The Notorious Case of Official Statistics
Gov APIs: The Notorious Case of Official Statistics
 
Design-first API Development using Swagger and Node
Design-first API Development using Swagger and NodeDesign-first API Development using Swagger and Node
Design-first API Development using Swagger and Node
 

Semelhante a Build a Restfull app using drupal

Semelhante a Build a Restfull app using drupal (20)

Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Deploy your Multi-tier Application in Cloud Foundry
Deploy your Multi-tier Application in Cloud FoundryDeploy your Multi-tier Application in Cloud Foundry
Deploy your Multi-tier Application in Cloud Foundry
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9
 
Drupalcon 2023 - How Drupal builds your pages.pdf
Drupalcon 2023 - How Drupal builds your pages.pdfDrupalcon 2023 - How Drupal builds your pages.pdf
Drupalcon 2023 - How Drupal builds your pages.pdf
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
 
Migrating data to drupal 8
Migrating data to drupal 8Migrating data to drupal 8
Migrating data to drupal 8
 
Headless Drupal
Headless DrupalHeadless Drupal
Headless Drupal
 
AngularJS
AngularJSAngularJS
AngularJS
 
Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
[drupalday2017] - Drupal come frontend che consuma servizi: HTTP Client Manager
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
 
RedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis code
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
 
Adriano Di Luzio - Davvy - PyconSEI Talk
Adriano Di Luzio - Davvy - PyconSEI TalkAdriano Di Luzio - Davvy - PyconSEI Talk
Adriano Di Luzio - Davvy - PyconSEI Talk
 
Drupal security
Drupal securityDrupal security
Drupal security
 

Último

Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 

Último (20)

(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
 
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 

Build a Restfull app using drupal

  • 1. MAY 29 & 30, 2014 Barcelona @alvar0hurtad0 Drupal’s API
  • 2.
  • 3. SO
  • 4. SO
  • 5. SO
  • 7.
  • 8. W
  • 9.
  • 10. T
  • 20.
  • 21. 7 8
  • 23. 7 8 IM • MULTILINGUAL • UX/ADMINISTRATION EXPERIENCE • MOBILE FRIENDLY • CONFIGURATION MANAGEMENT • WEB SERVICES
  • 26. 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
  • 27. Photo: Carlos Francisco Peña DATA MODEL
  • 28. Photo: Carlos Francisco Peña DATA MODEL
  • 29. Photo: Carlos Francisco Peña DATA MODEL
  • 30. Photo: Carlos Francisco Peña DATA MODEL 
 CONTENT MODELING • CONTENT TYPES • COMMENTS • USER PROFILES • COMMERCE PRODUCTS • ….
  • 44. SERVICES AUTHENTICATION IN CORE • HTTP basic authentication • Cookie
  • 45. SERVICES AUTHENTICATION IN CORE • HTTP basic authentication • Cookie CONTRIBUTED MODULE • Oauth
  • 46. SHOW ME THE CODE
  • 47. SHOW ME THE CODE 
 CURL curl -H "Accept: application/hal+json" --request GET http://drupal-8.localhost/node/1
  • 48. 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); ?>
  • 49. 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"}]}'
  • 50. 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')), );
  • 51. 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!'; } ?>
  • 52. SOAP?
  • 53. SOAP?
  • 54. SOAP?
  • 55. QUESTIONS !!! ?¿? !!! I’ve a question
  • 57.
  • 58.