How to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs
41.7 هزار بار بازدید -
3 سال پیش
-
PHP APIs course: ➤
PHP APIs course: ➤ davehollingworth.net/phpapisy
Support my channel: ☕ ko-fi.com/davehollingworth
There are several ways to make API calls from PHP. In this video we'll learn how to use each one, along with their advantages and disadvantages.
We'll cover the file_get_contents function, cURL, Guzzle and SDKs.
Details of the resources shown in the video and all the code used are below, including links to the RESTful APIs used.
Resources:
Testing API:
jsonplaceholder.typicode.com/
file_get_contents:
www.php.net/manual/en/function.file-get-contents.p…
www.php.net/manual/en/reserved.variables.httprespo…
www.php.net/manual/en/filesystem.configuration.php…
cURL:
curl.se/
www.php.net/manual/en/book.curl.php
www.php.net/manual/en/function.curl-setopt.php
www.php.net/manual/en/function.curl-getinfo.php
Guzzle:
docs.guzzlephp.org/
SDKs:
stripe.com/docs/libraries#server-side-libraries
stripe.com/docs/api/customers?lang=php
Code shown in the video:
gist.github.com/daveh/c61fbe671894a7931d88a5ca8273…
API icon made by Smashicons (www.flaticon.com/authors/smashicons) from Flaticon (www.flaticon.com/)
00:00 Introduction
00:38 file_get_contents
07:06 cURL
14:22 Guzzle
19:30 SDKs
24:22 Summary
#PHP #API #REST #cURL #Guzzle #SDK
3 سال پیش
در تاریخ 1400/05/17 منتشر شده
است.
41,713
بـار بازدید شده