2012-08-17 126 views
5

我试图使用邮件黑猩猩API发送电子邮件发送电子邮件,但下面的错误occours使用邮件黑猩猩API

{"aws_type":null,"aws_code":null,"http_code":500,"message":"Invalid Mailchimp API Key: <snip>-us5 . You are accessing the wrong datacenter - your client library may not properly support our datacenter mapping scheme."} 

我检查我的mailchimp API密钥和它的正确。如果有任何人知道,请回复如下 是我的代码

$apikey = 'api_key'; 

$to_emails = array('[email protected]'); 
$to_names = array('You', 'Your Mom'); 

$message = array(
    'html'=>'Yo, this is the <b>html</b> portion', 
    'text'=>'Yo, this is the *text* portion', 
    'subject'=>'This is the subject', 
    'from_name'=>'Me!', 
    'from_email'=>'[email protected]', 
    'to_email'=>$to_emails, 
    'to_name'=>$to_names 
); 

$tags = array('WelcomeEmail'); 

$params = array(
    'apikey'=>$apikey, 
    'message'=>$message, 
    'track_opens'=>true, 
    'track_clicks'=>false, 
    'tags'=>$tags 
); 

$url = "http://us1.sts.mailchimp.com/1.0/SendEmail"; 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url.'?'.http_build_query($params)); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$result = curl_exec($ch); 
echo $result; 
curl_close ($ch); 

$data = json_decode($result); 
echo "Status = ".$data->status."\n"; 
+0

只是一个问题:“为什么使用mailchimp发送时,你可以使用PHP自己发送?” – 2014-07-18 09:58:37

回答

2

没有做更多的研究,我想尝试改变$urlhttp://us5.sts.mailchimp.com/1.0/SendEmail自-us5 API键结束,它的抱怨,你击中了错误的数据中心。

+0

谢谢sblom,我改变了它,但之后,这个错误发生{“aws_type”:null,“aws_code”:null,“http_code”:500,“message”:“请先设置集成”}是否有任何其他集成组 – rohit 2012-08-17 05:57:12