Subsrcibe MailChimp API V3中的用户给出了错误的响应

时间:2015-12-30 08:27:12

标签: php mailchimp

当我尝试在mailchimp上订阅用户时,它会在下面粘贴错误:

‹<»nÃ0E…Вű2tòèt+ŠB‘[€.I¹0‚ü{i»è(Þ‹ÃC=Œ¬3šÁL"ómÀS'úìbòSÌsïk¶¡ú-±“X <ýÏìØb@¶HTé&LT;|Êìhμ|3%MU·²\'K#±R>áåréL@Q~ß'ú+· [Z“A× - ” pCØQNÇ=¼V,{AI&LT;£÷EA @ QOE¢¸Ó®Å'pDníuu,º¼øML_Gl†‡ÙQÇ4£1N•+〜·H ±§ħ «ÌT½;€ÛW|¹TÍóóùÿÿI*¯Q`

这是PHP代码:

$apiKey = 'YOUR API KEY';
$listId = 'YOUR LIST ID';
$url2 = 'https://us12.api.mailchimp.com/3.0/lists/'.$listId.'/members/';

$args = array(
        'email' => 'abc@xyz.com',
        'status' => 'subscribed',
        'merge_fields' => array(
            'first_name' => 'WOW',
            'last_name' => 'WOW',
            'mobile'=>'',
            'message'=>'',
            'ID'=>'000'
        ));

function syncMailchimp($url,$apiKey,$args) {

    $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        curl_setopt($ch, CURLOPT_USERPWD, "user apikey:" . $apiKey);
        curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
}

服务器是使用错误的编码发送错误数据还是客户端?如何解决?

1 个答案:

答案 0 :(得分:1)

将名为parent的密钥更改为email似乎已将其修复。也许这个糟糕的密钥导致服务器呕吐。

email_address

 $args = array(
        'email' => 'abc@xyz.com',
        'status' => 'subscribed',
        'merge_fields' => array(
            'first_name' => 'WOW',
            'last_name' => 'WOW',
            'mobile'=>'',
            'message'=>'',
            'ID'=>'000'
        ));