Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to parse a json mailgun sendmessage response in php?
    primarykey
    data
    text
    <p>Here is my code:</p> <pre><code>$this-&gt;view-&gt;assign('mail', $mail); $mg = new Mailgun($this-&gt;getMailgunAPIKey()); $domain = "sandbox1111.mailgun.org"; $res = $mg-&gt;sendMessage($domain, array('from' =&gt; 'bob@sandbox3445.mailgun.org', 'to' =&gt; 'mee@xxxxx.com', 'subject' =&gt; $mail-&gt;getSubject(), 'text' =&gt; $mail-&gt;getBody())); var_dump( $res); </code></pre> <p>and here is what gets printed out by the var_dump:</p> <pre><code>object(stdClass)#228 (2) { ["http_response_body"]=&gt; object(stdClass)#223 (2) { ["message"]=&gt; string(18) "Queued. Thank you." ["id"]=&gt; string(52) "&lt;20131211155824.31559.48115@sandbox1111.mailgun.org&gt;" } ["http_response_code"]=&gt; int(200) } </code></pre> <p>I tried <code>var_dump( json_decode($res));</code> but that prints out NULL. How do I access the ["http_response_code"] for instance?</p> <p>ANSWER: </p> <pre><code> var_dump( $res); echo __LINE__.'&lt;br/&gt;&lt;br/&gt;'; var_dump( $res-&gt;http_response_body ); echo __LINE__.$res-&gt;http_response_code.'&lt;br/&gt;&lt;br/&gt;'; echo $res-&gt;http_response_body-&gt;message.'&lt;br/&gt;&lt;br/&gt;'; </code></pre> <p>prints</p> <pre><code>object(stdClass)#228 (2) { ["http_response_body"]=&gt; object(stdClass)#223 (2) { ["message"]=&gt; string(18) "Queued. Thank you." ["id"]=&gt; string(52) "&lt;20131211161740.16663.18744@sandbox3445.mailgun.org&gt;" } ["http_response_code"]=&gt; int(200) } 150 object(stdClass)#223 (2) { ["message"]=&gt; string(18) "Queued. Thank you." ["id"]=&gt; string(52) "&lt;20131211161740.16663.18744@sandbox3445.mailgun.org&gt;" } 152200 Queued. Thank you. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload