-1
我正在使用curl更新遠程站點中的某些字段。但我完成的是: 我能夠登錄到遠程站點,能夠獲取我需要在curl請求中使用的csrf標記。但我不能夠設置頭參數爲捲曲 測試URL需要被http://singh.mobi//vishal/curl/proposalform1.php爲遠程域設置捲曲請求標頭
我的代碼是這樣的:
$ch1 = curl_init();
$data_string = '{""proposal"":{""id"":36854,""name"":""New proposal #9"",""template_id"":5107,""sections"":[],""custom_tokens"":[],""reload_template"":true}}';
curl_setopt($ch1, CURLOPT_URL, "http://alpha.niftyquoter.com/proposals/36854?cool_edit=true");
//$ch = curl_init('http://api.local/rest/users');
curl_setopt($ch1, CURLOPT_COOKIEJAR, '/home/brilliantmind/public_html/singh.mobi/vishal/curl/'.$cookie);
curl_setopt($ch1, CURLOPT_COOKIEFILE, '/home/brilliantmind/public_html/singh.mobi/vishal/curl/'.$cookie);
curl_setopt($ch1, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch1, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json', 'Origin: http://alpha.niftyquoter.com', 'Accept-Encoding: gzip,deflate,sdch',
'X-CSRF-Token: $authenticity_token','Accept: application/json','Referer: http://alpha.niftyquoter.com/proposals/36854?edit=true'
)
);
$result = curl_exec($ch1);
$header = curl_getinfo($ch1);
echo '<pre>';
print_r($header);
curl_close($ch1);
echo $output;