<?php header("Content-Type: text/html;charset=utf-8"); ////Get a long-lived token $appId="20185454500018";//Application APPID $appKey="qvegfhgfhG0qDei"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.yunhetong.com/api/auth/login", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, When CURLOPT_HEADER => true,//false, get the code CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"appId\":\"$appId\",\n\"appKey\":\"$appKey\"\n}", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err.die; } else { //echo $response; $headArr = explode("\r\n", $response); foreach ($headArr as $loop) { if(strpos($loop, "token") !== false){ $token = trim(substr($loop, 6)); //$token = trim($loop); } if(strpos($loop, "code") !== false){ //$code = trim(substr($loop, 6)); $rp = trim($loop); } } } $arr = json_decode($rp, true); $code = $arr['code'];//code=200 indicates success $msg = $arr['msg']; //unsuccessful if($code!="200" || !$token){ print_r( "Get long-lived token, reason: ".$msg).die; } ////$token="eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE1MjQ0NzI5MjEsImp0aSI6ImcxSlJHdDJzeHRNMXFMOU9ta2hVUVFkdXVsSzh4Sk5NcUlIbkE5eUgvYkJwbk5yeHEvYVY4TDVia0VQY051QzQyTlZicWhzKzByUjVHeDV6WGZ3N2d3PT0ifQ.NQd0ujuYk5ZrBHmmMvgx9JaVPH3qSXxcxlMNvkkp7zq3-d67wo5lubT_wkGqRukNmii7IoWM-vjxx8ax681abg"; //print_r($code).die; //create individual user $userName = "Zhong Anzhi";////User name (maximum 15 characters) Cheng Cainan $identityRegion = 0; ////Identity Region: 0 Mainland, 1 Hong Kong, 2 Taiwan, 3 Macau $certifyNum = "422827199911149418";////ID number, the only one in the app is 520181198002175907 $phoneRegion = 0;////Mobile phone number region: 0 mainland, 1 Hong Kong, Macau, 2 Taiwan $phoneNo = "13640550035";//Mobile phone number: 1. Mainland, the first one is 1, and the length is 11 digits; 2. Hong Kong, Macau, the length is 8; 3. Taiwan, the length is 10. $caType = "B1";//Certificate type: A1 CFCA scenario, A2 CFCA long-term, B1 ZJCA scenario, B2 ZJCA long-term $curl2 = curl_init(); curl_setopt_array($curl2, array( CURLOPT_URL => "https://api.yunhetong.com/api/user/person", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"caType\": \"$caType\",\n\"certifyNum\": \"$certifyNum\",\n\"identityRegion\": \"$identityRegion\",\n\"phoneNo\": \"$phoneNo\",\n\"phoneRegion\": \"$phoneRegion\",\n\"userName\": \"$userName\"\n}", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "token: $token" ), )); $response2 = curl_exec($curl2); $err2 = curl_error($curl2); curl_close($curl2); if ($err2) { echo "cURL Error #:" . $err2.die; } else { //echo $response2; $arr2 = json_decode($response2, true); $code2 = $arr2['code'];//code=200 indicates success $msg2 = $arr2['msg']; //unsuccessful if($code2!=200){ print_r( "Failed to create personal user, reason: ".$msg2).die; } $signerId = $arr2['data']['signerId']; } // $ signerId = 60; // echo $signerId; //create personal impression $curl3 = curl_init(); curl_setopt_array($curl3, array( CURLOPT_URL => "https://api.yunhetong.com/api/user/personMoulage", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"signerId\": \"$signerId\",\n\"borderType\": \"B2\",\n\"fontFamily\": \"F1\"\n}", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "token: $token" ), )); $response3 = curl_exec($curl3); $err3 = curl_error($curl3); curl_close($curl3); if ($err3) { echo "cURL Error #:" . $err3.die; } else { // echo $response3; $arr3 = json_decode($response3, true); $code3 = $arr3['code'];//code=200 indicates success $msg3 = $arr3['msg']; //unsuccessful if($code3!=200){ print_r( "Failed to create personal impression, reason: ".$msg3).die; } $castId = $arr3['data']['castId']; } //$moldingId=82; ////print_r($moldingId); //Generate contract based on template $contractTitle="Test contract title"; $templateId="TEM1001231"; $curl4 = curl_init(); curl_setopt_array($curl4, array( CURLOPT_URL => "https://api.yunhetong.com/api/contract/templateContract", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"contractTitle\": \"$contractTitle\",\n\"templateId\": \"$templateId\"\n}", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "token: $token" ), )); $response4 = curl_exec($curl4); $err4 = curl_error($curl4); curl_close($curl4); if ($err4) { echo "cURL Error #:" . $err4.die; } else { // echo $response4; $arr4 = json_decode($response4, true); $code4 = $arr4['code'];//code=200 indicates success $msg4 = $arr4['msg']; //unsuccessful if($code4!=200){ print_r( "Failed to create personal impression, reason: ".$msg4).die; } $ contractId = $ arr4 ['data'] ['contractId']; $contractId=str_replace(",","",number_format($contractId)); } print_r($contractId); //$contractId="1804232025535010"; //add signer $curl5 = curl_init(); curl_setopt_array($curl5, array( CURLOPT_URL => "https://api.yunhetong.com/api/contract/signer", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", //CURLOPT_POSTFIELDS => "{\n\"contractTitle\": \"$contractTitle\",\n\"templateId\": \"$templateId\"\n}", CURLOPT_POSTFIELDS => "{\"idType\": \"0\",\n\"idContent\": \"$contractId\",\n\"signers\": [{\"signerId\": \"$signerId\",\n\"signPositionType\": \"1\",\n\"positionContent\": \"88046\",\n\"signValidateType\": \"0\"}\n]\n}", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "token: $token" ), )); $response5 = curl_exec($curl5); $err5 = curl_error($curl5); curl_close($curl5); if ($err5) { echo "cURL Error #:" . $err5.die; } else { //echo $response5; $arr5 = json_decode($response5, true); $code5 = $arr5['code'];//code=200 indicates success $msg5 = $arr5['msg']; } //unsuccessful if($code5!=200){ print_r( "Failed to create personal impression, reason: ".$msg5).die; } // print_r($code5); //sign the contract $curl6 = curl_init(); curl_setopt_array($curl6, array( CURLOPT_URL => "https://api.yunhetong.com/api/contract/sign", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"idType\": \"0\",\n\"idContent\": \"$contractId\",\n\"signerId\": \"$signerId\",\n\"moulageId\": \"$moulageId\"\n}", CURLOPT_HTTPHEADER => array( "cache-control: no-cache", "content-type: application/json", "token: $token" ), )); $response6 = curl_exec($curl6); $err6 = curl_error($curl6); curl_close($curl6); if ($err6) { echo "cURL Error #:" . $err6.die; } else { echo $response6; $arr6 = json_decode($response6, true); $code6 = $arr6['code'];//code=200 indicates success $msg6 = $arr6['msg']; } //unsuccessful if($code6!=200){ print_r( "Failed to sign contract, reason: ".$msg6).die; } // print_r($code6); ?>
Completely generate a cloud contract instance
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324775806&siteId=291194637
Recommended
Ranking