MailChimp响应代码200

时间:2015-03-04 08:35:48

标签: php httpresponse mailchimp

我正在运行MailChimp subscribe API调用。发送的JSON对象如下所示:

{  
   "apikey":"someAPIkey-us10",
   "id":"someID",
   "email":{  
      "email":"example@su.vi"
   },
   "merge_vars":{  
      "products":[  
         {  
            "name":"prod",
            "url":"https:\/\/www.example.co.uk\/properties\/link\/sub\/res",
            "price":"\u00a3378.00",
            "location":"loc",
            "area":"are"
         }
      ]
   },
   "double_optin":false
}

和执行curl对象的php代码如下所示:

$curl = curl_init(SEED_URL);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, 
    array(
        "Accept: application/json",
        "Content-Type: application/json",
        "Content-Length: " . strlen($jsonStr)
    )
);
$response = curl_exec($curl);
var_dump($response);
$responseCode = curl_getinfo ($curl , CURLINFO_HTTP_CODE);
    if ($responseCode !== 201) {
        throw new Exception("post failed with response code " . $responseCode . " " . $jsonStr, 1);
    }

$response转储有效,如下所示:

"{"email":"example@su.vi","euid":"someEUID","leid":"someLEID"}"

然而

  

发布失败,回复代码为200。

抛出

,并且没有在mailChimp服务器中填充订户列表。

1 个答案:

答案 0 :(得分:1)

HTTP代码200表示您的请求成功。见https://apidocs.mailchimp.com/api/2.0/

您只需等待几分钟即可查看您的订阅者列表。