Skip to content

Commit d0f02eb

Browse files
author
tuck1s
committed
Update base request example
1 parent 3148865 commit d0f02eb

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ Sends an asynchronous request to the SparkPost API and returns a `SparkPostPromi
183183
* Type: `Array`
184184
* Recipients to descreetly recieve a carbon copy of the transmission
185185

186-
For complete list of endpoints, refer to [API documentation](https://developers.sparkpost.com/api/).
187-
188186
## Examples
189187

190188
### Send An Email Using The Transmissions Endpoint
@@ -269,6 +267,7 @@ More examples [here](./examples/):
269267
- get (with retry logic)
270268

271269
### Send An API Call Using The Base Request Function
270+
272271
We provide a base request function to access any of our API resources.
273272
```php
274273
<?php
@@ -279,17 +278,20 @@ use GuzzleHttp\Client;
279278
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
280279

281280
$httpClient = new GuzzleAdapter(new Client());
282-
$sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
281+
$sparky = new SparkPost($httpClient, [
282+
'key' => getenv('SPARKPOST_API_KEY'),
283+
'async' => false]);
283284

284-
$promise = $sparky->request('GET', 'metrics/ip-pools', [
285-
'from' => '2014-12-01T09:00',
286-
'to' => '2015-12-01T08:00',
287-
'timezone' => 'America/New_York',
288-
'limit' => '5',
289-
]);
285+
$webhookId = 'afd20f50-865a-11eb-ac38-6d7965d56459';
286+
$response = $sparky->request('DELETE', 'webhooks/' . $webhookId);
287+
print($response->getStatusCode());
290288
?>
291289
```
292290

291+
> Be sure to not have a leading `/` in your resource URI.
292+
293+
For complete list of resources, refer to [API documentation](https://developers.sparkpost.com/api/).
294+
293295
## Handling Responses
294296
The API calls either return a `SparkPostPromise` or `SparkPostResponse` depending on if `async` is `true` or `false`
295297

0 commit comments

Comments
 (0)