Subsrcibe a user in MailChimp API V3 给出错误响应


Subsrcibe a user in MailChimp API V3 give bad response

当我尝试在mailchimp上订阅用户时,它给出了粘贴在下面的错误响应:

‹<»nÃ0E…Вű2tòèt+ŠB‘[€.I¹0‚ü{i»è(Þ‹ÃC=Œ¬3šÁL"ó mÀS'úìbòSÌsïk¶¡ú–±ˆ"X‹ýïìØ b@¶HTé<¦Êìhμ¦3%mÜ·² ̧'''k#±R›áåréL@Q ̃ß'ú+·[ž"À×–">pCØQNÇ=1/4V'{ÄÎ<£÷èá@q Œ¢ ̧Ó®Å'pDníuu,º1/4ø ML_Gl†‡ÙQÇ4£1n•+~·H±§?H ̧«ÌT1/2;€Û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;
}

服务器是否发送了错误数据或客户端使用了错误的编码,我该如何解决?

将名为 email 的密钥更改为 email_address 似乎已经修复了它。 也许那个错误的密钥导致服务器呕吐。

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

$args = array(
        'email_address' => 'abc@xyz.com',
        'status' => 'subscribed',
        'merge_fields' => array(
            'first_name' => 'WOW',
            'last_name' => 'WOW',
            'mobile'=>'',
            'message'=>'',
            'ID'=>'000'
        ));
相关文章: