Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Leeds PHP: Guzzle and SDKs Example Snippets
<?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