Php Mandrill提供无效的应用程序密钥错误
我只是尝试将mandrill邮件发送与我的应用程序集成,下面是我的php代码Php Mandrill提供无效的应用程序密钥错误,php,codeigniter,email,mailchimp,Php,Codeigniter,Email,Mailchimp,我只是尝试将mandrill邮件发送与我的应用程序集成,下面是我的php代码 $args = array( 'key' => '73357ad2-e59e-4669---------', 'message' => array( "html" => "<p>\r\n\tHi Adam,</p>\r\n<p>\r\n\tThanks for <a href=\"http://mandrill.com\">
$args = array(
'key' => '73357ad2-e59e-4669---------',
'message' => array(
"html" => "<p>\r\n\tHi Adam,</p>\r\n<p>\r\n\tThanks for <a href=\"http://mandrill.com\">registering</a>.</p>\r\n<p>etc etc</p>",
"text" => null,
"from_email" => "xxx@xxx.com",
"from_name" => "SIVOnline",
"subject" => "Your recent registration",
"to" => array(array("email" => "xxx@xxx.com")),
"track_opens" => true,
"track_clicks" => true,
"auto_text" => true
)
);
// Open a curl session for making the call
$curl = curl_init('https://mandrillapp.com/api/1.0/messages/send.json' );
// Tell curl to use HTTP POST
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Tell curl not to return headers, but do return the response
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
// Set the POST arguments to pass on
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args));
// Make the REST call, returning the result
$response = curl_exec($curl);
// Close the connection
curl_close( $curl );
$args=array(
“键”=>“73357ad2-e59e-4669------”,
'消息'=>数组(
“html”=>“\r\n\tHi Adam,\r\n\r\n\t感谢。\r\n等”,
“text”=>null,
“从电子邮件”=>“xxx@xxx.com",
“from_name”=>“SIVOnline”,
“主题”=>“您最近的注册”,
到“=>数组(数组(“电子邮件”=>)xxx@xxx.com")),
“轨迹_打开”=>为真,
“track_clicks”=>true,
“自动文本”=>真
)
);
//打开一个curl会话进行呼叫
$curl=curl\u init('https://mandrillapp.com/api/1.0/messages/send.json' );
//告诉curl使用httppost
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
//告诉curl不要返回标题,但一定要返回响应
curl_setopt($curl,CURLOPT_头,false);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-Type:application/json'));
//设置要传递的POST参数
curl_setopt($curl,CURLOPT_POSTFIELDS,json_encode($args));
//进行REST调用,返回结果
$response=curl\u exec($curl);
//关闭连接
curl_close($curl);
在重新生成密钥后,它给了我无效的api密钥,但我仍然得到了相同的错误。在将
$args
变量传递给CURLOPT_POSTFIELDS setopt调用时,不要对其进行JSON编码
顺便说一句,您应该首先尝试进行一个users/ping调用。提示:您可以获得一个功能齐全的PHP Mandrill API包装类
。。。它包含在WordPress插件包中:如果您使用的是位于此处的Mandrill官方API 你会这样做吗
require_once(Mandrill.php);
$apikey = "YOUR-API-KEY";
$Mandrill = new Mandrill($apikey);
$params = array(
"html" => "<p>\r\n\tHi Adam,</p>\r\n<p>\r\n\tThanks for <a href=\"http://mandrill.com\">registering</a>.</p>\r\n<p>etc etc</p>",
"text" => null,
"from_email" => "xxx@xxx.com",
"from_name" => "chris french",
"subject" => "Your recent registration",
"to" => array(array("email" => "xxx@xxxx.com")),
"track_opens" => true,
"track_clicks" => true,
"auto_text" => true
);
$Mandrill->messages->send($params, true);
require_一次(Mandrill.php);
$apikey=“YOUR-API-KEY”;
$Mandrill=新Mandrill($apikey);
$params=数组(
“html”=>“\r\n\tHi Adam,\r\n\r\n\t感谢。\r\n等”,
“text”=>null,
“从电子邮件”=>“xxx@xxx.com",
“from_name”=>“chris french”,
“主题”=>“您最近的注册”,
到“=>数组(数组(“电子邮件”=>)xxx@xxxx.com")),
“轨迹_打开”=>为真,
“track_clicks”=>true,
“自动文本”=>真
);
$Mandrill->messages->send($params,true);
首先让用户/ping呼叫做什么?@Williams Castillo-就像916网络一样,首先检查用户/ping呼叫的目的是什么?