diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -5,7 +5,10 @@ # SparkPost PHP Library [](https://travis-ci.org/SparkPost/php-sparkpost) -[](https://coveralls.io/github/SparkPost/php-sparkpost?branch=master) [](http://slack.sparkpost.com) +[](https://coveralls.io/github/SparkPost/php-sparkpost?branch=master) +[](https://packagist.org/packages/sparkpost/sparkpost) +[](https://packagist.org/packages/sparkpost/sparkpost) +[](http://slack.sparkpost.com) The official PHP library for using [the SparkPost REST API](https://developers.sparkpost.com/api/). @@ -48,7 +51,7 @@ requiring a request library. This means that your application will need to pass a request adapter to the constructor of the SparkPost Library. We use the [HTTPlug](https://github.com/php-http/httplug) in SparkPost. Please visit their repo for a list of supported [clients and adapters](http://docs.php-http.org/en/latest/clients.html). If you don't currently use a request library, you will need to require one and create a client from it and pass it along. The example below uses the GuzzleHttp Client Library. -An Client can be setup like so: +A Client can be setup like so: ```php <?php @@ -97,7 +100,11 @@ $sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']); * Type: `Boolean` * Default: `true` * `async` defines if the `request` function sends an asynchronous or synchronous request. If your client does not support async requests set this to `false` - +* `options.debug` + * Required: No + * Type: `Boolean` + * Default: `false` + * If `debug` is true, then then all `SparkPostResponse` and `SparkPostException` instances will return any array of the request values through the function `getRequest` ## Methods ### request(method, uri [, payload [, headers]]) @@ -168,7 +175,6 @@ use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $httpClient = new GuzzleAdapter(new Client()); $sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']); -$sparky = new SparkPost($httpClient, $options); $promise = $sparky->transmissions->post([ 'content' => [ 'from' => [ @@ -205,6 +211,7 @@ $promise = $sparky->transmissions->post([ ], ], ]); +?> ``` ### Send An API Call Using The Base Request Function @@ -226,6 +233,7 @@ $promise = $sparky->request('GET', 'metrics/ip-pools', [ 'timezone' => 'America/New_York', 'limit' => '5', ]); +?> ``` @@ -295,6 +303,8 @@ An exception will be thrown in two cases: there is a problem with the request or * Returns the exception message * **getBody()** * If there is a response body it returns it as an `Array`. Otherwise it returns `null`. +* **getRequest()** + * Returns an array with the request values `method`, `url`, `headers`, `body` when `debug` is `true` ### Contributing |