|
在PHP里面模拟post提交,先是要访问网站获取图片验证和返回cookie,然后再手动打码提交data和cookie到网址,我试了curl和file_get_contents_post都说验证码错误或者失效,估计是COOKIE的问题,请大神帮忙解决下http://www.onini.cn/qcmz5t1k 这是网站 2017121320004001110025125214 这是订单号,随便生成的都可以,购买之后提交订单多次就要输入验证码,我用php模拟提交返回的都是说验证码错误或失效,
我用了下面的函数能够获取到cookie和图片但是后面提交的时候还是说验证码错误或者失效
function getimg ($url,$referer )
{
$optionlogin = array ( 'http' => array ( 'method' => "GET" , 'header' => "User-Agent:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.0.04506; CIBA)/r/nAccept:*/*/r/nReferer:" . $referer));
$file = file_get_contents ( $url , false , stream_context_create( $optionlogin ));
session_start();
$_SESSION [ "doCookie" ] = $http_response_header;
$_SESSION['cookies']=strstr($_SESSION [ "doCookie" ][11],';',true);
return $file ;
}
$url = "http://www.onini.cn/Home/Vcode?rdm=0.".mt_rand(100000,999999).mt_rand(100000,999999).mt_rand(100000,999999);
$img = getimg($url,'http://www.onini.cn/qcmz5t1k');
file_put_contents('img',$img);
echo '<img src="img">';
function file_get_contents_post($url, $post) {
$options = array(
'http' => array(
'method' => 'POST',
'header' =>'Cookie:'.$_SESSION['cookies'],
'content' => http_build_query($post),
),
);
$result = file_get_contents($url, false, stream_context_create($options));
return $result;
}
$status = @file_get_contents_post("http://www.onini.cn/Home/Tiqu", array('goodsId'=>'2452', 'alipayTradeNo'=>"'".$num."'",'vcode'=>"'".$code."'",'domain'=>'qcmz5t1k'));
echo $status ;// //检查是否转账成功
|
|