diff options
author | Elmer Thomas <elmer@ThinkingSerious.com> | 2016-09-13 09:26:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-13 09:26:57 -0700 |
commit | 55ffd690f9309e0d3331bf9e2daa4ac2eac4ab94 (patch) | |
tree | 9a94aec7e6879e6e9ffbb448782277bf4e75f582 /examples | |
parent | 23193453f681d77adf3f4ac6981e62e26c698537 (diff) | |
parent | e5de48e78b1d2d8421562a5a424a170813c0e69c (diff) | |
download | php-http-client-3.2.0.zip php-http-client-3.2.0.tar.gz php-http-client-3.2.0.tar.bz2 |
Merge pull request #6 from misantron/refactoringv3.2.0
Library refactoring around PSR-2 / PSR-4 code standards
Diffstat (limited to 'examples')
-rw-r--r-- | examples/example.php | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/examples/example.php b/examples/example.php index 1eb8c41..ce86d73 100644 --- a/examples/example.php +++ b/examples/example.php @@ -1,31 +1,32 @@ <?php + // If running this outside of this context, use the following include and // comment out the two includes below // require __DIR__ . '/vendor/autoload.php'; -include(dirname(__DIR__).'/lib/SendGrid/client.php'); +include(dirname(__DIR__) . '/lib/Client.php'); // This gets the parent directory, for your current directory use getcwd() $path_to_config = dirname(__DIR__); -$api_key = getenv('SENDGRID_API_KEY'); -$headers = array('Authorization: Bearer '.$api_key); -$client = new SendGrid\Client('https://api.sendgrid.com', $headers, '/v3', null); +$apiKey = getenv('SENDGRID_API_KEY'); +$headers = ['Authorization: Bearer ' . $apiKey]; +$client = new SendGrid\Client('https://api.sendgrid.com', $headers, '/v3'); // GET Collection -$query_params = array('limit' => 100, 'offset' => 0); -$request_headers = array('X-Mock: 200'); +$query_params = ['limit' => 100, 'offset' => 0]; +$request_headers = ['X-Mock: 200']; $response = $client->api_keys()->get(null, $query_params, $request_headers); echo $response->statusCode(); echo $response->body(); echo $response->headers(); // POST -$request_body = array( - 'name' => 'My PHP API Key', - 'scopes' => array( - 'mail.send', - 'alerts.create', - 'alerts.read' - ) -); +$request_body = [ + 'name' => 'My PHP API Key', + 'scopes' => [ + 'mail.send', + 'alerts.create', + 'alerts.read' + ] +]; $response = $client->api_keys()->post($request_body); echo $response->statusCode(); echo $response->body(); @@ -40,22 +41,22 @@ echo $response->body(); echo $response->headers(); // PATCH -$request_body = array( - 'name' => 'A New Hope' -); +$request_body = [ + 'name' => 'A New Hope' +]; $response = $client->api_keys()->_($api_key_id)->patch($request_body); echo $response->statusCode(); echo $response->body(); echo $response->headers(); // PUT -$request_body = array( - 'name' => 'A New Hope', - 'scopes' => array( - 'user.profile.read', - 'user.profile.update' - ) -); +$request_body = [ + 'name' => 'A New Hope', + 'scopes' => [ + 'user.profile.read', + 'user.profile.update' + ] +]; $response = $client->api_keys()->_($api_key_id)->put($request_body); echo $response->statusCode(); echo $response->body(); @@ -66,5 +67,3 @@ $response = $client->api_keys()->_($api_key_id)->delete(); echo $response->statusCode(); echo $response->body(); echo $response->headers(); - -?>
\ No newline at end of file |