这是我的代码
<?php //if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once APPPATH."/libraries/REST_Controller.php";
require_once APPPATH."/libraries/echosign.php";
class Document_management extends Rest_Controller
{
public function get_access_token_get()
{
$echoSign = new EchoSign();
$ch = curl_init('https://secure.echosign.com/api/rest/v2/auth/tokens');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($echoSign->echosign_creds));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = json_decode(curl_exec($ch));
curl_close($ch);
return $result->accessToken;
}
public function get_agreements_get()
{
$accessToken = array("Access-Token: ".$this->get_access_token_get());
$ch = curl_init('https://secure.echosign.com:443/api/rest/v2/agreements');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $accessToken);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$result = json_decode(curl_exec($ch));
curl_close($ch);
$agreements = array(
"agreementId" => $result->userAgreementList[0]->agreementId,
"name" => $result->userAgreementList[0]->name,
);
return $agreements;
}
public function get_form_data_get($headers, $agreements)
{
$filepath = APPPATH."files/".$agreements['name']."csv";
$url = 'https://secure.echosign.com:443/api/rest/v2/agreements/'.$agreements['agreementId'].'/formData';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
//header("Content-type: text/csv");
//header("Content-Disposition: attachment; filename=".$filepath);
$result = curl_exec($ch);
//echo "<pre>"; print_r($result); echo "</pre>"; exit();
curl_close($ch);
}
public function download_file_get()
{
$headers = array("Access-Token: ".$this->get_access_token_get());
$agreements = $this->get_agreements_get();
$this->get_form_data_get($headers, $agreements);
}
}
?>浏览器中的输出只是以这种格式发送表单的原始数据
"completed","email","role","first","last","title","company","agreementId","firstname","lastname" "2014-11-04 15:55:44","abe.taha@gmail.com","SIGNER","Abe","Taha","Web Developer","","2AAABLblqZhDrvBK47mPKPZW-VSAJKDHASFT42ESlPxOjYphH4C0A5_adasdasda6qnFCy2idJ8*","ABE","TAHA"我不知道如何将流存储在变量中,甚至不知道如何分解它以将其存储在数据库中。
我尝试过使用php://input或readfile和其他选项来读取流,但不知道如何格式化数据
发布于 2015-01-13 23:18:47
看起来您正在使用EchoSign REST API GET /agreements/{agreementId}/formData,并希望了解有关其输出的更多详细信息。上面的调用生成一个CSV (逗号分隔的文件)。
如果调用成功,则此返回参数将包含以逗号分隔的数据值,并以换行符分隔每条记录。第一行将始终包含标题值-即所有列的键。
在密钥agreementId引用特定协议的情况下,该协议的每个签名者将有另一行,该行中的每一项都是签名者输入的表单值,对应于适当的标头。
https://stackoverflow.com/questions/27142768
复制相似问题