嗨伙计们,
我非常了解如何在 php/curl 中编程并使用可用的选项。
我想知道,如果我们想将数据发布到网站(在我的情况下,我必须通过单击本质上是 javascript 的链接来回答网站中的问题)但是我使用的 LIVEhttpHeaders 插件不提供发布数据。也就是说,当我单击所需的链接时,插件会显示以下内容
http://www.xyz.com/ans.do?q=X2&id=cX&cid=1&oid=5
POST /ans.do?q=X2&id=cX&cid=1&oid=5 HTTP/1.1
Host: xyz.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://www.xyz.com/Quiz.do?qId=291241
Cookie: __utma=1.399093274.1364213174.1365000359.1365004345.14;
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Content-Length: 0
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Language: en-US
Content-Length: 5876
Date: Wed, 03 Apr 2013 15:59:02 GMT
我已经创建了一个 curl 脚本并且已经达到了测验..并且可以解析需要的参数( q,id,cid,oid 等)。但是我如何实际发布数据(单击选项),因为它们没有 POST_FIELD ???
到目前为止,我一直使用以下代码
$url_c="$ser/ans.do?q=$q&id=$id&cid=$cid&oid=$oid;
$url_p="$ser/Quiz.do?qId=$qid";
curl_setopt($ch, CURLOPT_URL,$url_c);
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $url_p);
$html=curl_exec($ch);
但选项仍然如此。尝试将 POST 设置为 1 , FOLLOWLOCATION ,但可以正常工作。
我可以帮忙吗???