PHPcURLを使用してUPSにログインする方法の2012年頃の例が必要です。通話の合間にセッションを閉じていません。フェッチするページは3つあります。1)ログインページ2)パスワードページ3)請求書ページ
以前は動作していましたが、現在は動作していません。Cookieファイルを削除してしばらくの間機能しましたが、「現在のリクエストは非アクティブのためタイムアウトになりました。リクエストを再開する必要があります。」というメッセージが表示されます。ウィンドウ内でログインしないと、ログインに成功してもタイムアウトになります。Cookieファイルを削除してやり直してみましたが、うまくいきませんでした。タイムアウトウィンドウが無限になるようにする方法はありますか?これが私が持っているコードで、クレデンシャルが削除されています:
$cookie_file_path = "/tmp/cookie.txt";
// remove previous cookie
if (file_exists($cookie_file_path)) {
`rm -fr {$cookie_file_path}`;
}
$login_url = 'https://www.ups.com/one-to-one/login';
$password_url = 'https://www.ups.com/one-to-one/password';
$invoice_url = 'upsDOTcomSLASHviewbillSLASHinvoices';
$agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0";
$login_data = "sysid=null&lang=null&langc=null&method=null&returnto=null&loc=en_US&uid=<user_id>&rememberMe=1&next=Next&pm_fp=version%253D1%2526pm%255Ffpua%253Dmozilla%252F5%252E0%2520%2528windows%2520nt%25206%252E1%253B%2520wow64%253B%2520rv%253A10%252E0%2529%2520gecko%252F20100101%2520firefox%252F10%252E0%257C5%252E0%2520%2528Windows%2529%257CWin32%2526pm%255Ffpsc%253D24%257C1920%257C1200%257C1160%2526pm%255Ffpsw%253D%257Cqt6%257Cqt5%257Cqt4%257Cqt3%257Cqt2%257Cqt1%257Cswf%257Cpdf%257Cpdf%2526pm%255Ffptz%253D%252D5%2526pm%255Ffpln%253Dlang%253Den%252DUS%257Csyslang%253D%257Cuserlang%253D%2526pm%255Ffpjv%253D1%2526pm%255Ffpco%253D1";
$password_data = "sysid=null&lang=null&langc=null&method=null&returnto=null&loc=en_US&password=<password>&next=Log+In&pm_fp=version%253D1%2526pm%255Ffpua%253Dmozilla%252F5%252E0%2520%2528windows%2520nt%25206%252E1%253B%2520wow64%253B%2520rv%253A10%252E0%2529%2520gecko%252F20100101%2520firefox%252F10%252E0%257C5%252E0%2520%2528Windows%2529%257CWin32%2526pm%255Ffpsc%253D24%257C1920%257C1200%257C1160%2526pm%255Ffpsw%253D%257Cqt6%257Cqt5%257Cqt4%257Cqt3%257Cqt2%257Cqt1%257Cswf%257Cpdf%257Cpdf%2526pm%255Ffptz%253D%252D5%2526pm%255Ffpln%253Dlang%253Den%252DUS%257Csyslang%253D%257Cuserlang%253D%2526pm%255Ffpjv%253D1%2526pm%255Ffpco%253D1";
$headers[] = "Accept: */*";
$headers[] = "Connection: Keep-Alive";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, 'https://www.ups.com/myups/login');
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
ob_start();
$result = curl_exec ($ch);
ob_end_clean();
echo curl_error($ch); // prints nothing if successful
//curl_close($ch);
//$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $password_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $password_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $login_url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
ob_start();
$result = curl_exec ($ch);
ob_end_clean();
echo curl_error($ch) // prints nothing if successful
//curl_close($ch);
//$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $invoice_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/html; charset=utf-8'));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $invoice_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $password_url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
ob_start();
$result = curl_exec ($ch);
ob_end_clean();
echo curl_error($ch); // prints nothing if successful
curl_close($ch);
次のように、Cookieファイルを削除して再作成した後でも、最初のログインページを通過できません。
非アクティブなため、現在のリクエストはタイムアウトになりました。リクエストを再開する必要があります。
どんな助けでも大歓迎です。