SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
WP HTTP API Eunus Hosen! 
Co-Founder & CTO! 
DevsTeam
What is HTTP API
Why HTTP API 
❖ cURL : A library to communicate with remote hosts. Works only 
when the cURL extension is loaded into PHP.! 
❖ File system (fopen, file_get_contents) : This function opens up a file 
or an URL and this works when php ini_settings allows for this.! 
❖ Sockets (fsockopen) : Initiates a socket connection to the resource 
specified by host-name. Again it’s possible that the hosting company 
might have disabled the fsockopen function.! 
❖ Streams: Works on PHP 4.3 or later.! 
❖ HTTP: Provides a powerful request and parallel interface for remote 
calls. It needs PHP 5.2+
WP_HTTP Class
Helper Functions 
❖ wp_remote_get() - Retrieves a URL using the GET HTTP 
method.! 
❖ wp_remote_post() - Retrieves a URL using the POST HTTP 
method.! 
❖ wp_remote_head() - Retrieves a URL using the HEAD 
HTTP method.! 
❖ wp_remote_request() - Retrieves a URL using either the 
default GET or a custom HTTP method (should be caps) 
that you specify.
An Example
Response
Retrieve Body: wp_remote_retrieve_body($response)
Retrieve Body: wp_remote_retrieve_headers($response)
More Helper Functions 
❖ wp_remote_retrieve_body() - Retrieves just the body from the response.! 
❖ wp_remote_retrieve_header() - Gives you a single HTTP header based 
on name from the response.! 
❖ wp_remote_retrieve_headers() - Returns all of the HTTP headers in an 
array for processing.! 
❖ wp_remote_retrieve_response_code() - Gives you the number for the 
HTTP response. This should be 200, but could be 4xx or even 3xx on 
failure.! 
❖ wp_remote_retrieve_response_message() - Returns the response 
message based on the response code
Resources 
❖ wp_remote_get: http://codex.wordpress.org/Function_Reference/wp_remote_get! 
❖ wp_remote_post: http://codex.wordpress.org/Function_Reference/wp_remote_post! 
❖ wp_remote_head: http://codex.wordpress.org/Function_Reference/wp_remote_head! 
❖ wp_remote_retrieve_body : http://codex.wordpress.org/Function_Reference/ 
wp_remote_retrieve_body! 
❖ wp_remote_retrieve_headers : http://codex.wordpress.org/Function_Reference/ 
wp_remote_retrieve_headers! 
❖ wp_remote_retrieve_header: http://codex.wordpress.org/Function_Reference/ 
wp_remote_retrieve_header! 
❖ wp_remote_retrieve_response_code : http://codex.wordpress.org/Function_Reference/ 
wp_remote_retrieve_response_code! 
❖ wp_remote_retrieve_response_message : http://codex.wordpress.org/Function_Reference/ 
wp_remote_retrieve_response_message
Got a Question?
Thank you!

Contenu connexe

Tendances

Php Server Var
Php Server VarPhp Server Var
Php Server Var
arvind34
 
Apache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hosting
webhostingguy
 

Tendances (20)

Psr 7 symfony-day
Psr 7 symfony-dayPsr 7 symfony-day
Psr 7 symfony-day
 
Php workshop L04 database
Php workshop L04 databasePhp workshop L04 database
Php workshop L04 database
 
Php workshop L03 superglobals
Php workshop L03 superglobalsPhp workshop L03 superglobals
Php workshop L03 superglobals
 
Php Server Var
Php Server VarPhp Server Var
Php Server Var
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster Unleashed
 
PHP language presentation
PHP language presentationPHP language presentation
PHP language presentation
 
[India Merge World Tour] Meru Networks
[India Merge World Tour] Meru Networks[India Merge World Tour] Meru Networks
[India Merge World Tour] Meru Networks
 
File Uploading in PHP
File Uploading in PHPFile Uploading in PHP
File Uploading in PHP
 
Internationalization with TYPO3
Internationalization with TYPO3Internationalization with TYPO3
Internationalization with TYPO3
 
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
Intro KaKao MRTE (MySQL Realtime Traffic Emulator)
 
Php 5.5
Php 5.5Php 5.5
Php 5.5
 
Real-Time Django
Real-Time DjangoReal-Time Django
Real-Time Django
 
Introduction to Symfony Components and helper components in Drupal 8
Introduction to Symfony Components and helper components in Drupal 8Introduction to Symfony Components and helper components in Drupal 8
Introduction to Symfony Components and helper components in Drupal 8
 
Varnish
VarnishVarnish
Varnish
 
Caching on the Edge
Caching on the EdgeCaching on the Edge
Caching on the Edge
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
 
Apache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hosting
 
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011WordPress Theme & Plugin development best practices - phpXperts seminar 2011
WordPress Theme & Plugin development best practices - phpXperts seminar 2011
 

En vedette

Introduction to Web Development Career
Introduction to Web Development CareerIntroduction to Web Development Career
Introduction to Web Development Career
Eunus Hosen
 
Premio Ramazzini & Carvalho
Premio  Ramazzini & CarvalhoPremio  Ramazzini & Carvalho
Premio Ramazzini & Carvalho
Gonzalo De La Peña
 
2014 (1) debriefing
2014 (1) debriefing2014 (1) debriefing
2014 (1) debriefing
Uma Chitra
 
Brocher ciri guru inovatif
Brocher ciri guru inovatifBrocher ciri guru inovatif
Brocher ciri guru inovatif
Uma Chitra
 
Apec women and the economy 2011 mo - australia
Apec women and the economy 2011   mo - australiaApec women and the economy 2011   mo - australia
Apec women and the economy 2011 mo - australia
otoolem
 
An example of cms - wordpress
An example of cms - wordpressAn example of cms - wordpress
An example of cms - wordpress
Eunus Hosen
 
Women and the economy
Women and the economyWomen and the economy
Women and the economy
otoolem
 

En vedette (17)

WordPress Coding Standards & WP Hooks
WordPress Coding Standards & WP HooksWordPress Coding Standards & WP Hooks
WordPress Coding Standards & WP Hooks
 
Introduction to Web Development Career
Introduction to Web Development CareerIntroduction to Web Development Career
Introduction to Web Development Career
 
Career on WordPress: How to get started with WordPress
Career on WordPress: How to get started with WordPressCareer on WordPress: How to get started with WordPress
Career on WordPress: How to get started with WordPress
 
Premio Ramazzini & Carvalho
Premio  Ramazzini & CarvalhoPremio  Ramazzini & Carvalho
Premio Ramazzini & Carvalho
 
CV-Malawi
CV-MalawiCV-Malawi
CV-Malawi
 
Unique engineering
Unique engineeringUnique engineering
Unique engineering
 
2014 (1) debriefing
2014 (1) debriefing2014 (1) debriefing
2014 (1) debriefing
 
Branding highlights2002b
Branding highlights2002bBranding highlights2002b
Branding highlights2002b
 
Brocher ciri guru inovatif
Brocher ciri guru inovatifBrocher ciri guru inovatif
Brocher ciri guru inovatif
 
Lp week 1
Lp week 1Lp week 1
Lp week 1
 
Fan Page Biz-In-A-Box
Fan Page Biz-In-A-BoxFan Page Biz-In-A-Box
Fan Page Biz-In-A-Box
 
Apec women and the economy 2011 mo - australia
Apec women and the economy 2011   mo - australiaApec women and the economy 2011   mo - australia
Apec women and the economy 2011 mo - australia
 
An example of cms - wordpress
An example of cms - wordpressAn example of cms - wordpress
An example of cms - wordpress
 
Jeres powerpoint
Jeres powerpointJeres powerpoint
Jeres powerpoint
 
Protokoler
ProtokolerProtokoler
Protokoler
 
Women and the economy
Women and the economyWomen and the economy
Women and the economy
 
Introduction to WordPress
Introduction to WordPressIntroduction to WordPress
Introduction to WordPress
 

Similaire à WP HTTP API

nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
hazzaz
 
MidwestPHP Symfony2 Internals
MidwestPHP Symfony2 InternalsMidwestPHP Symfony2 Internals
MidwestPHP Symfony2 Internals
Raul Fraile
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
Nat Weerawan
 
Tips
TipsTips
Tips
mclee
 

Similaire à WP HTTP API (20)

nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
 
REST library.pptx
REST library.pptxREST library.pptx
REST library.pptx
 
Salesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP calloutsSalesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP callouts
 
New Features in PHP 5.3
New Features in PHP 5.3New Features in PHP 5.3
New Features in PHP 5.3
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
MidwestPHP Symfony2 Internals
MidwestPHP Symfony2 InternalsMidwestPHP Symfony2 Internals
MidwestPHP Symfony2 Internals
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML Resources
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11
 
Tips
TipsTips
Tips
 
Master the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and Silex
 
RESTful for opentravel.org by HP
RESTful for opentravel.org by HPRESTful for opentravel.org by HP
RESTful for opentravel.org by HP
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
PHP MySQL Training : Module 3
PHP MySQL Training : Module 3PHP MySQL Training : Module 3
PHP MySQL Training : Module 3
 
Under the Covers with the Web
Under the Covers with the WebUnder the Covers with the Web
Under the Covers with the Web
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

WP HTTP API

  • 1. WP HTTP API Eunus Hosen! Co-Founder & CTO! DevsTeam
  • 3. Why HTTP API ❖ cURL : A library to communicate with remote hosts. Works only when the cURL extension is loaded into PHP.! ❖ File system (fopen, file_get_contents) : This function opens up a file or an URL and this works when php ini_settings allows for this.! ❖ Sockets (fsockopen) : Initiates a socket connection to the resource specified by host-name. Again it’s possible that the hosting company might have disabled the fsockopen function.! ❖ Streams: Works on PHP 4.3 or later.! ❖ HTTP: Provides a powerful request and parallel interface for remote calls. It needs PHP 5.2+
  • 5. Helper Functions ❖ wp_remote_get() - Retrieves a URL using the GET HTTP method.! ❖ wp_remote_post() - Retrieves a URL using the POST HTTP method.! ❖ wp_remote_head() - Retrieves a URL using the HEAD HTTP method.! ❖ wp_remote_request() - Retrieves a URL using either the default GET or a custom HTTP method (should be caps) that you specify.
  • 10. More Helper Functions ❖ wp_remote_retrieve_body() - Retrieves just the body from the response.! ❖ wp_remote_retrieve_header() - Gives you a single HTTP header based on name from the response.! ❖ wp_remote_retrieve_headers() - Returns all of the HTTP headers in an array for processing.! ❖ wp_remote_retrieve_response_code() - Gives you the number for the HTTP response. This should be 200, but could be 4xx or even 3xx on failure.! ❖ wp_remote_retrieve_response_message() - Returns the response message based on the response code
  • 11. Resources ❖ wp_remote_get: http://codex.wordpress.org/Function_Reference/wp_remote_get! ❖ wp_remote_post: http://codex.wordpress.org/Function_Reference/wp_remote_post! ❖ wp_remote_head: http://codex.wordpress.org/Function_Reference/wp_remote_head! ❖ wp_remote_retrieve_body : http://codex.wordpress.org/Function_Reference/ wp_remote_retrieve_body! ❖ wp_remote_retrieve_headers : http://codex.wordpress.org/Function_Reference/ wp_remote_retrieve_headers! ❖ wp_remote_retrieve_header: http://codex.wordpress.org/Function_Reference/ wp_remote_retrieve_header! ❖ wp_remote_retrieve_response_code : http://codex.wordpress.org/Function_Reference/ wp_remote_retrieve_response_code! ❖ wp_remote_retrieve_response_message : http://codex.wordpress.org/Function_Reference/ wp_remote_retrieve_response_message