这是我的代码
<?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);
}
}
?>
浏览器中的输出只是以这种格式发送表单的RAW数据
"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 和其他选项来读取流,但不明白如何格式化数据