SlideShare ist ein Scribd-Unternehmen logo
1 von 59
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Andere mochten auch

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)Ignacio Elola Villar
 
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 versionQuentin Adam
 
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)javier ramirez
 
Enhance the browser_experience
Enhance the browser_experienceEnhance the browser_experience
Enhance the browser_experienceHTML5 Spain
 
AIL Platform APIDays Mediterranea
AIL Platform APIDays MediterraneaAIL Platform APIDays Mediterranea
AIL Platform APIDays MediterraneaJoan Protasio
 
The importance of /me
The importance of /meThe importance of /me
The importance of /meBruno Pedro
 
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 trenchesDaniel Cerecedo
 
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 StatisticsXavier Badosa
 
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 NodeApigee | Google Cloud
 

Andere mochten auch (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
 

Ähnlich wie Build a Restfull app using drupal

Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGapAlex S
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGapAlex S
 
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 Foundrycornelia davis
 
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...Alex S
 
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...DrupalCampDN
 
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 9Acquia
 
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.pdfLuca Lusso
 
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 pagessparkfabrik
 
Headless Drupal
Headless DrupalHeadless Drupal
Headless Drupaldrubb
 
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 9Mediacurrent
 
[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 ManagerDrupalDay
 
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.xJoão Ventura
 
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.Samuel Solís Fuentes
 
RedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedis Labs
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareOpevel
 
Adriano Di Luzio - Davvy - PyconSEI Talk
Adriano Di Luzio - Davvy - PyconSEI TalkAdriano Di Luzio - Davvy - PyconSEI Talk
Adriano Di Luzio - Davvy - PyconSEI Talkaldur999
 
Drupal security
Drupal securityDrupal security
Drupal securityJozef Toth
 

Ähnlich wie 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
 

Kürzlich hochgeladen

『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesLumiverse Solutions Pvt Ltd
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 

Kürzlich hochgeladen (9)

『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best Practices
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 

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.