From 394bf061e00b96bd67447e6be67b1e3733e76f1e Mon Sep 17 00:00:00 2001 From: Travis Swientek Date: Mon, 19 Aug 2013 14:46:34 -0700 Subject: [PATCH] Updated README --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 9d52a84..0ea05fe 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,53 @@ $mg->get("$domain/log", array('limit' => 25, 'skip' => 0); ``` +Result +------ + +The results, provided by the endpoint, are returned as an object, which you can traverse like an array. + +Example: + +```php +$mg = new Mailgun("key-example"); +$domain = "example.com"; + +$result = $mg->get("$domain/log", array('limit' => 25, + 'skip' => 0); + +$httpResponseCode = $result->http_response_code; +$httpResponseBody = $result->http_response_body; +``` + +Example Contents: +$httpResponseCode will contain an integer. You can find how we use HTTP response codes in our documentation: http://documentation.mailgun.com/api-intro.html?highlight=401#errors + +$httpResponseBody will contain an object of the API response. In the above example, a var_dump($result) would contain the following: + +``` +["http_response_body"]=> + object(stdClass)#31 (2) { + ["total_count"]=> + int(62) + ["items"]=> + array(1) { + [0]=> + array(5) { + ["hap"]=> + string(10) "tempfailed" + ["created_at"]=> + string(29) "Mon, 19 Aug 2013 19:41:33 GMT" + ["message"]=> + string(155) "Will retry in 14400 seconds: me@samples.mailgun.org → sergeyo@profista.com 'Hello' No MX for [profista.com] Server response: 498 No MX for [profista.com]" + ["type"]=> + string(4) "warn" + ["message_id"]=> + string(46) "20130819113429.18813.89868@samples.mailgun.org" + } + } + } +``` + For usage examples on each API endpoint, head over to our official documentation pages. This SDK includes a [Message Builder](src/Mailgun/Messages/README.md) and [Batch Message](src/Mailgun/Messages/README.md) component.