Created
May 12, 2020 12:36
-
-
Save lornajane/f6fa6ed543c2d250c220dd648656f506 to your computer and use it in GitHub Desktop.
Leeds PHP: Guzzle and SDKs Example Snippets
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 | |
// composer require guzzlehttp/guzzle | |
require "vendor/autoload.php"; | |
$client = new GuzzleHttp\Client(["base_uri" => "https://api.github.com/"]); | |
try { | |
$response = $client->get("/users/lornajane/repos"); | |
if($response->getStatusCode() == 200) { | |
$json = $response->getBody(); | |
$data = json_decode((string)$json, true); | |
print_r($data); | |
} | |
} catch (Exception $e) { | |
print_r($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment