回LS,不需要登录,通过发送post请求得到返回数据就行 ------------------ 刚才试了下还是报错 Notice: Use of undefined constant POSTFIELDS - assumed 'POSTFIELDS' in 。。Warning: curl_setopt() expects parameter 2 to be long, string given in 。。错误信息:未将对象引用设置到对象的实例。1 ------------------------------ 我用firebug打开来看源站的情况,post数据显示是 cid 85487 page 1 而不是cid=85487&page=1的形式, Content-Type application/x-www-form-urlencoded请问我还需要怎么设置才可能正确取到响应。
以下为引用的内容:// 1. 初始化
$ch = curl_init();
// 2. 设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, "http://www.baidu.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. 执行并获取HTML文档内容
$output = curl_exec($ch);
// 4. 释放curl句柄
curl_close($ch);
呢
curl_setopt($ch, POSTFIELDS, $postdata); //$postdata 可以是url参数串或关联数组。键名请自行保证与对方表单处理程序一致
------------------
刚才试了下还是报错
Notice: Use of undefined constant POSTFIELDS - assumed 'POSTFIELDS' in 。。Warning: curl_setopt() expects parameter 2 to be long, string given in 。。错误信息:未将对象引用设置到对象的实例。1 ------------------------------
我用firebug打开来看源站的情况,post数据显示是
cid 85487
page 1
而不是cid=85487&page=1的形式,
Content-Type application/x-www-form-urlencoded请问我还需要怎么设置才可能正确取到响应。
curl我不怎么懂,可是经常用Snoopy来抓取数据,可以模拟post提交,你可以看下
正确的是
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);