我正在嘗試使用DocuSign API創建recipientView。我試圖使用捲曲庫郵政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:連接被拒絕 – Jodo1992
這就是問題所在。我添加了這個信息的答案。 –