Skip to content

Instantly share code, notes, and snippets.

@lornajane
Created May 12, 2020 12:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lornajane/f6fa6ed543c2d250c220dd648656f506 to your computer and use it in GitHub Desktop.
Save lornajane/f6fa6ed543c2d250c220dd648656f506 to your computer and use it in GitHub Desktop.
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