[英]Mailgun - Invalid resource type: array on put method
我正在使用mailgun php sdk。 但是當我嘗試從郵件列表更新用戶時,我收到錯誤(無效的資源類型:數組) 。 我的代碼如下。
$client = new \Http\Adapter\Guzzle6\Client();
$mgClient = new \Mailgun\Mailgun('YOUR_API_KEY', $client);
$listAddress = 'LIST@YOUR_DOMAIN_NAME';
$memberAddress = 'bob@example.com';
# Issue the call to the client.
$result = $mgClient->put("lists/$listAddress/members/$memberAddress", array(
'subscribed' => 'no',
'name' => 'Foo Bar'
));
首先,確保您使用的是最新版本的php-http/guzzle6-adapter
,然后嘗試以下操作:
$client = \Http\Adapter\Guzzle6\Client::createWithConfig([
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
]
]);
$mgClient = new \Mailgun\Mailgun('YOUR_API_KEY', $client);
$listAddress = 'LIST@YOUR_DOMAIN_NAME';
$memberAddress = 'bob@example.com';
# Issue the call to the client.
$result = $mgClient->put("lists/$listAddress/members/$memberAddress", http_build_query([
'subscribed' => 'no',
'name' => 'Foo Bar'
]));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.