当使用Mailgun的官方PHP SDK(2.8)成功将邮件排队时,我非常困惑如何读取API响应。
// First, instantiate the SDK with your API credentials
$mg = Mailgun::create('key-example'); // For US servers
$mg = Mailgun::create('key-example', 'https://api.eu.mailgun.net'); // For EU servers
// Now, compose and send your message.
// $mg->messages()->send($domain, $params);
$response = $mg->messages()->send('example.com', [
'from' => 'bob@example.com',
'to' => 'sally@example.com',
'subject' => 'The PHP SDK is awesome!',
'text' => 'It is so simple to send a message.'
]);
var_dump($response);
//Var dump results object(Mailgun\Model\Message\SendResponse)#130 (2) { ["id":"Mailgun\Model\Message\SendResponse":private]=> string(52) "<201949588013742.1.5234966234A248269@mydomain.com>" ["message":"Mailgun\Model\Message\SendResponse":private]=> string(18) "Queued. Thank you." }
$ response是一个私有对象,我无法阅读“已排队。谢谢”。在里面。我在文档中找不到任何相关的功能。我在这里想念什么吗?
答案 0 :(得分:1)
您可以通过此获得以下数据
对于ID:$response->getId()
消息:$response->getMessage()
欢呼