dongzhuo5185 2019-01-31 13:09
浏览 60
已采纳

使用OAuth2.0的PHP Adob​​eSign API :: transientDocuments

I am using PHP OAuth2.0 Adobesign API for sending pdf to user for e-signature purpose.

I successfully generate auth token and refresh token by following basic OAuth2 steps.

Now I am facing issue while trying to send pdf transientDocuments using curl code. Below is my sample code:

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();

Output:

{
    "code": "NO_FILE_CONTENT",
    "message": "Must provide file body"
}
  • 写回答

2条回答 默认 最新

  • duandange7480 2019-02-04 11:58
    关注

    Finally I come to know Adobe Esign with V6 having some issue with this method. So I switch to V5 and make some little modification in my code. It is working for me.

    <?php
    define("AUTH_URL", "https://api.na2.echosign.com/api/rest/v5/transientDocuments");
    
    $url = AUTH_URL;
    $header =array(
            "Authorization: Bearer 3AAAB6hBTt666543359kgBzroaNxqyezwBRdsdsdssssssssss6767gGy7CNdERHxqz1r5lOzmyxI7hfQ22zsyCDvnG_HRc8m9B7UBRJuGy", 
            "cache-control: no-cache",
            "content-type: multipart/form-data",
            "Content-Disposition: form-data; name='File'; filename='MyPDF.pdf'",
        );
    
    $filePath= '@'.file_get_contents('MyPDF.pdf');
    $fields = array('File' => $filePath,'Mime-Type' => 'application/pdf', 'File-Name' => 'MyPDF.pdf');
    
    $resource = curl_init();
    curl_setopt_array($resource, array(
      CURLOPT_URL => $url,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => $fields,
      CURLOPT_HTTPHEADER => $header
    ));
    
    
    $res = curl_exec($resource);
    $result = json_decode($res,true);
    echo "<pre>";
    print_r($result);
    echo "</pre>";
    curl_close($resource);
    ?>
    

    Output:

    Array
    (
        [transientDocumentId] => 3AA777777777777gwxctQX8kTYj2e3Esgc5_HbvKgKK_oaIccNqr2JwWJK8bUXn779OMvyFMJG2VONbbbMqO-bo_GoKJP-wfYszcQtg7tbJ8sc8YxTwQPm3kV77777ThgQy5ZoeHb_km-zmitgdSkf7sLYp0vCO8CAbvYQVzd3OpU6zJ-Mv54VoVKvsYUFsfhfhgK]epKpCHnvKWvn37fghfg777876rV2QYyh9bkApotXvSzxndXNQbUTmAcpP1Jq-WlXsVdGleKjHoEMoDgfhfghIOYQFxy5eeOtctqwtxC9MUWjioGV6FW6ZtoGm0ijqGU*
    )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记