2012-02-14 4 views
0

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); 

내가 먹을수록 내가, 심지어 삭제 및 쿠키 파일을 다시 생성 한 후 첫 로그인 페이지 번번이 할 수

현재 요청이 초과되었습니다 비활성으로 인해. 요청을 다시 시작해야합니다.

도움을 주시면 감사하겠습니다.

+0

보인다. –

+0

UPS에는 그런 것들을위한 API가 있습니다. –

답변

1
  1. 다른 서버에서 연결을 시도하십시오. 어쩌면 당신이 블랙리스트에 올랐을 수도 있습니다.
  2. CURLOPT_FRESH_CONNECT 또는 CURLOPT_FORBID_REUSE 컬 옵션으로 실행하십시오. 그것은이 작업을 수행하는 서비스의 업 조건을 위반처럼
  3. 방문 로그인 페이지 게시물 데이터를 제출 중 전에
0

예 나는 지루했으나, 여기 왜 그렇게해서는 안됩니다. UPS 기술 계약의

1.2 F :

자동 액세스 할 수 있습니다. 제한없이 자동 검색 장치, 로봇 또는 반복적 인 데이터 수집 및 추출 도구, 루틴, 스크립트 또는 비슷한 기능을 가진 다른 메커니즘이 UPS 시스템 또는 호스트 된 UPS 기술에 대한 액세스는 UPS 본 계약의 목적은 명시 적으로 을 금지합니다.

+0

아, 알았어. 글쎄, 불행히도 나는 그것을 수동으로해야 할 것이다. 그들은 이것을위한 API를 가지고 있지 않습니다. 추적 및 평가 API를 가지고 있지만 인보이스 발행 API는 없습니다. 의견에 감사드립니다. – user1207994

+0

나는 그 (것)들을 위해 작동하지 않는다, 나는 너가 그것을 어쨌든하는 경우에 그들에게 말하지 않을 것이다 : -) –

관련 문제