我PHP OAuth2.0 Adobesign API
用于将 pdf 发送给用户以进行电子签名。
我按照基本的 OAuth2 步骤成功生成了身份验证令牌和刷新令牌。
现在我在尝试使用 curl 代码发送 pdf transientDocuments 时遇到问题。下面是我的示例代码:
define("CALLBACK_URL", "https://www.getdadstrong.com/vipin/test.php");
define("AUTH_URL", "https://api.in1.echosign.com/api/rest/v6/transientDocuments");
define("ACCESS_TOKEN_URL", "http://api.in1.echosign.com/oauth/token");
define("CLIENT_ID", "MY_CLIENT_ID");
define("CLIENT_SECRET", "MY_CLIENT_SECRET");
define("SCOPE", "agreement_send:account"); // optional
function getToken(){
$curlFILE = curl_init();
$params = array(
CURLOPT_URL => AUTH_URL,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_NOBODY => false,
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer MY_SECURE_TOKEN",
"cache-control: no-cache",
"content-type: multipart/form-data",
"Content-Disposition: form-data; name='file'; filename='MyPDF.pdf'",
),
CURLOPT_POSTFIELDS => array (
// 'filename' => new CURLFile('./MyPDF.pdf')
'filename' => new CURLFile('./MyPDF.pdf','application/pdf','MyFile')
),
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => FALSE
);
curl_setopt_array($curlFILE, $params);
$response = curl_exec($curlFILE);
curl_close($curlFILE);
$err = curl_error($curlFILE);
if ($err) {
echo "<br/> cURL Error #01: " . $err;
}
echo '<pre>';
var_dump($err);
var_dump($response);
echo '<pre>';
}
getToken();
输出:
{
"code": "NO_FILE_CONTENT",
"message": "Must provide file body"
}