我正在尝试发布一个表格,其中destionation网址不是我的服务器。
我在curl post的响应标题中收到此消息
HTTP/1.1 401 Unauthorized
X-Frame-Options: SAMEORIGIN
Set-Cookie: kjses=19d6fb64-be95-49d9-9145-005d0fbdbd60^KaV8Q0ZjHd0ow0/cbEg60A==; Path=/; HttpOnly
Transfer-Encoding: chunked
Date: Thu, 25 Aug 2016 00:15:52 GMT
Server: None
如果我在本地服务器上创建一个html页面来模拟表单,当我提交表单时,它的工作正常。这让我觉得错误来自我的卷曲设置,因为他们(其他网站)不阻止来自其他来源的帖子
这是我的卷曲
$param = array(
"token" => "1472083067316"
,"from" => "mail@hotmail.com"
,"fromName" => "Bob"
,"message" => "unbeaugrosmessage"
,"bbToken" => "gfdg4t3gfg"
,"bbUserInput" => "3183"
,"_sendCopyToSender" => "on"
,"adId" => "1193173128");
$postvars = '';
foreach($param as $key=>$value)
{
$postvars .= $key . "=" . $value . "&";
}
$curl = curl_init();
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: ";
$tmpfname = '/home/seb/ui/app/storage/logs/laravel.log';
curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36");
curl_setopt($curl, CURLOPT_COOKIEJAR, $tmpfname);
curl_setopt($curl, CURLOPT_COOKIEFILE, $tmpfname);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, 1); //0 for a get request
curl_setopt($curl, CURLOPT_POSTFIELDS,$postvars);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$result=curl_exec($curl);
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $header_size);
$body = substr($result, $header_size);
Log::error($header);
Log::error($body);
Log::error(curl_exec($curl));
curl_close($curl);
Log::error($result);
结果为空