Last active
August 24, 2016 17:27
-
-
Save mosampaio/94dbff24b7e561a1960ffc5f9ca965e1 to your computer and use it in GitHub Desktop.
How to consume a json Rest API with PHP using PHP Curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("user-agent: my app")); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/twilio/twilio-php/contributors"); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
print_r(json_decode($result, true)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment