PHP cURL을 사용하여 UPS에 로그인하는 방법에 대한 2012 년경의 예가 필요합니다. 통화 사이의 세션을 닫지 않을 것입니다. 가져올 페이지가 3 개 있습니다. 1) 로그인 페이지 2) 비밀번호 페이지 3) 송장 페이지PHP cURL을 사용하여 UPS.com에 로그인하는 방법
이전에는 작동했지만 더 이상 사용하지 않았습니다. 쿠키 파일을 삭제하고 잠시 동안 작동 한 다음 "현재 요청이 비활성으로 인해 시간이 초과되었습니다. 요청을 다시 시작해야합니다."라는 메시지가 나타납니다. 창문에 로그인하지 않으면 로그인이 성공하더라도 시간이 초과됩니다. 쿠키 파일을 삭제하고 다시 시작했지만 작동하지 않았습니다. 모든 아이디어가 그것을 만드는 방법 그래서 제한 시간 창은 무한하다? 여기에 내가, 자격 증명을 제거한 코드는 다음과 같습니다
$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);
내가 먹을수록 내가, 심지어 삭제 및 쿠키 파일을 다시 생성 한 후 첫 로그인 페이지 번번이 할 수
현재 요청이 초과되었습니다 비활성으로 인해. 요청을 다시 시작해야합니다.
도움을 주시면 감사하겠습니다.
보인다. –
UPS에는 그런 것들을위한 API가 있습니다. –