How to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs

HomeOther Content, TechHow to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs
How to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs
How to call APIs from PHP: file_get_contents, cURL, Guzzle and SDKs
PHP APIs course: https://davehollingworth.net/phpapisy
Support my channel: https://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:
https://jsonplaceholder.typicode.com/

file_get_contents:
https://www.php.net/manual/en/function.file-get-contents.php
https://www.php.net/manual/en/reserved.variables.httpresponseheader.php
https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

cURL:
https://curl.se/
https://www.php.net/manual/en/book.curl.php
https://www.php.net/manual/en/function.curl-setopt.php
https://www.php.net/manual/en/function.curl-getinfo.php

Guzzle:
https://docs.guzzlephp.org/

SDKs:
https://stripe.com/docs/libraries#server-side-libraries
https://stripe.com/docs/api/customers?langphp

Code shown in the video:
https://gist.github.com/daveh/c61fbe671894a7931d88a5ca82734921

API icon made by Smashicons (https://www.flaticon.com/authors/smashicons) from Flaticon (https://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

Take the opportunity to connect and share this video with your friends and family if you find it useful.

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *