【发布时间】:2016-07-08 20:18:54
【问题描述】:
我正在尝试使用 DocuSign API 创建recipientView。我正在尝试使用 cURL 库在 PHP 中发布请求,但由于某种原因,在执行我的代码时,下面代码中的 $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); 行返回 0:
$url = "http://demo.docusign.net/restapi/v2/accounts/$account_id/envelopes/
$envelope_id/views/recipient";
$body = array("returnUrl" => "http://www.docusign.com/devcenter",
"authenticationMethod" => "None",
"email" => "$recipient",
"userName" => "$recipient");
$body_string = json_encode($body);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Content-Length: '.strlen($body_string),
'Authorization: Bearer '.$access_token
));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body_string);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo $status;
$response = json_decode($jason_response, true);
$url = $response["url"];
我通过 JSON 发送 POST,我应该得到的响应是 JSON。为什么我的curl_exec() 失败并生成$status = 0?
【问题讨论】:
-
尝试在
curl_exec调用之后添加curl_error($curl),看看是否返回任何错误消息。 -
执行此操作时的错误是:无法连接到 demo.docusign.net 端口 80:连接被拒绝
-
那就是问题所在。我用这些信息添加了一个答案。
标签: php json post curl docusignapi