简体   繁体   中英

Mailgun - Invalid resource type: array on put method

I am working with mailgun php sdk. But I am getting error (Invalid resource type: array) when I try to update a user from mailing list. My Code is bellow.

$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'
));

First, make sure you are using the last version of php-http/guzzle6-adapter , then try the following:

$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'
]));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM