diff --git a/README.md b/README.md index 3f83ba9..1b8286f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Mailgun-PHP =========== -[![Build Status](https://travis-ci.org/travelton/Mailgun-PHP.png?branch=master)](https://travis-ci.org/travelton/Mailgun-PHP) +[![Build Status](https://travis-ci.org/mailgun/mailgun-php.png)](https://travis-ci.org/mailgun/mailgun-php) This is the Mailgun PHP SDK. This SDK contains methods for easily interacting with the Mailgun API. @@ -82,6 +82,12 @@ $result = $mg->get("$domain/log", array('limit' => 25, $httpResponseCode = $result->http_response_code; $httpResponseBody = $result->http_response_body; + +# Iterate through the results and echo the message IDs. +$logItems = $result->http_response_body->items; +for($logItems as $logItem){ + echo $logItem->message_id . "\n"; +} ``` Example Contents: diff --git a/src/Mailgun/Connection/RestClient.php b/src/Mailgun/Connection/RestClient.php index 3efa0c9..a0dd487 100644 --- a/src/Mailgun/Connection/RestClient.php +++ b/src/Mailgun/Connection/RestClient.php @@ -78,12 +78,9 @@ class RestClient{ public function responseHandler($responseObj){ $httpResponeCode = $responseObj->getStatusCode(); if($httpResponeCode === 200){ - $jsonResponseData = $responseObj->json(); + $jsonResponseData = json_decode($responseObj->getBody(), false); $result = new \stdClass(); - $result->http_response_body = new \stdClass(); - foreach ($jsonResponseData as $key => $value){ - $result->http_response_body->$key = $value; - } + $result->http_response_body = $jsonResponseData; } elseif($httpResponeCode == 400){ throw new MissingRequiredMIMEParameters(EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); diff --git a/src/Mailgun/Messages/README.md b/src/Mailgun/Messages/README.md index e177f06..b8b8b3f 100644 --- a/src/Mailgun/Messages/README.md +++ b/src/Mailgun/Messages/README.md @@ -104,16 +104,16 @@ domain. $batchMsg = $mg->BatchMessage($domain); # Define the from address. -$batchMsg->setFromAddress("me@samples.mailgun.org", array("first"=>"PHP", "last" => "SDK")); +$batchMsg->setFromAddress("me@example.com", array("first"=>"PHP", "last" => "SDK")); # Define the subject. $batchMsg->setSubject("A Batch Message from the PHP SDK!"); # Define the body of the message. $batchMsg->setTextBody("This is the text body of the message!"); # Next, let's add a few recipients to the batch job. -$batchMsg->addToRecipient("john.doe@samples.mailgun.org", array("first" => "John", "last" => "Doe")); -$batchMsg->addToRecipient("sally.doe@samples.mailgun.org", array("first" => "Sally", "last" => "Doe")); -$batchMsg->addToRecipient("mike.jones@samples.mailgun.org", array("first" => "Mike", "last" => "Jones")); +$batchMsg->addToRecipient("john.doe@example.com", array("first" => "John", "last" => "Doe")); +$batchMsg->addToRecipient("sally.doe@example.com", array("first" => "Sally", "last" => "Doe")); +$batchMsg->addToRecipient("mike.jones@example.com", array("first" => "Mike", "last" => "Jones")); ... // After 1,000 recipeints, Batch Message will automatically post your message to the messages endpoint.