我正在尝试从需要登录的页面查看状态(我有高级会员资格)
但是在运行脚本时,它没有检索到登录信息-是不是我的登录curl脚本遗漏了什么?
$curl=curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'https://reg.racingpost.com/mpp/sign_in.sd');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, array('signinEmail'=>'...@....com', 'signinPassword1'=>'.....'));
curl_setopt($curl, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');
curl_exec($curl);
curl_close($curl);
$curl=curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'http://www.racingpost.com/horses/result_home.sd?race_id=650156&r_date=2016-05-29');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
echo curl_exec($curl);
curl_close($curl);发布于 2016-05-30 18:51:10
问题可能出在变量的键上:
curl_setopt($curl, CURLOPT_POSTFIELDS, array('signinEmail'=>'...@....com', 'signinPassword1'=>'.....'));应该是:
curl_setopt($curl, CURLOPT_POSTFIELDS, array('signInEmail'=>'...@....com', 'signInPassword1'=>'.....'));
^ here ^ and here发布于 2016-05-30 19:14:34
我希望这能有所帮助。
$post_user_values = array(
'username' => USERNAME,
'password' => PASSWORD
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_user_values);发布于 2016-05-30 19:21:44
如果http://www.racingpost.com/horses/result_home.sd?race_id=650156&r_date=2016-05-29需要登录,那么不要关闭curl并使用相同的Curl init发出另一个curl请求。Se以下代码
$curl=curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'https://edeveloper.mppglobal.com/interface/Mpp/eDeveloper/v8/eDeveloper.json.svc/UserAuthenticateByEmail');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array('EmailAddress'=>'...@....com', 'UserPassword'=>'.....')));
curl_setopt($curl, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');
curl_exec($curl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'http://www.racingpost.com/horses/result_home.sd?race_id=650156&r_date=2016-05-29');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
echo curl_exec($curl);
curl_close($curl);https://stackoverflow.com/questions/37523621
复制相似问题