【发布时间】:2013-09-09 22:53:44
【问题描述】:
当我使用 curl 将 json 数据发布到 API 时 - 我没有得到任何输出。我想向收件人发送电子邮件邀请。
$url_send ="http://api.address.com/SendInvitation?";
$str_data = json_encode($data);
function sendPostData ($url, $post) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
return curl_exec($ch);
}
这里是JSON $str_data
[
{
"authorizedKey" : "abbad35c5c01-xxxx-xxx",
"senderEmail" : "myemail@yahoo.com",
"recipientEmail" : "jaketalledo86@yahoo.com",
"comment" : "Invitation",
"forceDebitCard" : "false"
}
]
以及调用函数:
$response = sendPostData($url_send, $str_data);
这是 API:https://api.payquicker.com/Help/Api/POST-api-SendInvitation
【问题讨论】: