summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormisantron <misantron@gmail.com>2016-08-21 21:08:00 +0300
committermisantron <misantron@gmail.com>2016-08-21 21:08:00 +0300
commite5de48e78b1d2d8421562a5a424a170813c0e69c (patch)
tree9a94aec7e6879e6e9ffbb448782277bf4e75f582
parent7d49213e23d922ab76ddfdbd6f456046862e8685 (diff)
downloadphp-http-client-e5de48e78b1d2d8421562a5a424a170813c0e69c.zip
php-http-client-e5de48e78b1d2d8421562a5a424a170813c0e69c.tar.gz
php-http-client-e5de48e78b1d2d8421562a5a424a170813c0e69c.tar.bz2
Example fix
-rw-r--r--examples/example.php49
1 files changed, 24 insertions, 25 deletions
diff --git a/examples/example.php b/examples/example.php
index a3119d1..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/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