用的是 curl 的 post 提交,可是当我提交给 phpwind 时候 会出现 “非法请求,请返回重试!”的问题。
贴出代码:
$url='http://bbs.xxx.com/post.php?';
$post_fields = '
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="atc_usesign"
1
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="replytouser"
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="atc_convert"
1
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="atc_autourl"
1
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="step"
2
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="type"
ajax_addfloor
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="action"
reply
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="fid"
152
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="pid"
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="cyid"
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="tid"
12531290
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="stylepath"
houdaov3
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="ajax"
1
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="verify"
8bf9a1f3
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="_hexie"
1bd43ba8
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="iscontinue"
0
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="atc_title"
123
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="atc_content"
666
------WebKitFormBoundaryLxTpwutjFfCXkj40
Content-Disposition: form-data; name="usernames"
------WebKitFormBoundaryLxTpwutjFfCXkj40--
';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
1
yylzcom 2015-12-24 05:39:02 +08:00 via Android 1
去模拟发一次帖子然后抓包,我记得 Discuz 和 PHP wind 都是有验证值在页面里, post 的时候是要带上验证值的。 post 之前先抓一次页面拿到这个值,然后作为一个参数提交。
|
2
pynix 2015-12-24 06:16:16 +08:00 1
PHP 用 curl 好麻烦的样子。。。
|
3
pynix 2015-12-24 06:16:56 +08:00 1
chrome devtool 里面看下 network 应该可以找到问题。
|
4
pynix 2015-12-24 06:17:23 +08:00 1
里面有 copy as curl
|
5
ly710 2015-12-24 09:47:42 +08:00 1
只做过 discuz ,要先去访问一个页面把页面表单里隐藏的值抓下来再去 post 的。
|