doubairan4213 2016-06-12 06:20
浏览 57

Mailgun - 无效的资源类型:数组on put方法

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'
));
  • 写回答

1条回答 默认 最新

  • dongwu5743 2016-06-24 04:18
    关注

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

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序