2011-10-24 59 views
0

我正在嘗試使用curl登錄basecamp並下載附件。cURL無法登錄basecamp

但是,當我蜷縮:

curl -F "username=my-user&password=my-pwd" "https://my-domain.basecamphq.com/login" 

這不是驗證。輸出:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 

<head> 
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> 
    <meta name="robots" content="noindex, nofollow" /> 
    <meta name="csrf-param" content="authenticity_token"/> 
<meta name="csrf-token" content="H5w&#47;7j9I5s38oQ9NdVgpkp&#47;QCxIZ3YW+qM&#47;+Hj&#47;ERr0="/> 
    <title>My Domain Name.: Sign in</title> 
    <script src="https://my-domain.basecamphq.com/rev_28dd107/sprockets.js?651551a0be3439fa32557210a7eea7d7" type="text/javascript"></script> 
    <link href="https://my-domain.basecamphq.com/rev_28dd107/application.css" media="screen" rel="stylesheet" type="text/css" /> 
    <link href="https://my-domain.basecamphq.com/rev_28dd107/stylesheets/print/application.css" media="print" rel="stylesheet" type="text/css" /> 

    <!--[if IE]><link href="https://my-domain.basecamphq.com/rev_28dd107/stylesheets/ie/base.css" media="screen" rel="stylesheet" type="text/css" /><![endif]--> 


    <meta name="queenbee-id" content="1152680" /> 

    <meta name="return-to-location" content="" /> 

    <script type="text/javascript"> 
    if (Login.recoverSessionToken()) { 
     Login.clearPersistedTokens(); 
     window.location = ""; 
    } 
    </script> 

</head> 

<body class="login"> 


    <div class="login"> 
     <h1>My Domain Name.</h1> 







<div id="login_dialog" class="login_dialog"> 
    <form accept-charset="UTF-8" action="https://launchpad.37signals.com/authenticate" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="H5w/7j9I5s38oQ9NdVgpkp/QCxIZ3YW+qM/+Hj/ERr0=" /></div> 
    <input id="product" name="product" type="hidden" value="basecamp" /> 
    <input id="subdomain" name="subdomain" type="hidden" value="my-domain" /> 

    <div id="user_name_login"> 
     <h2>Username</h2> 
     <input autocapitalize="off" autocorrect="off" id="username" name="username" type="text" /><br/> 

     <h2>Password</h2> 
     <input id="password" name="password" type="password" /><br/> 

     <label><input class="auto" id="remember_me" name="remember_me" type="checkbox" value="1" /> Remember me on this computer</label><br /> 

     <input class="button" name="commit" type="submit" value="Sign in" /> 

     <div class="extras"> 
     <ul> 
      <li><strong>Help:</strong> <a href="/amnesia/forgot_password">I forgot my username or password</a></li> 
     </ul> 
     </div> 
    </div> 
</form></div> 

<script type="text/javascript"> 
//<![CDATA[ 
$("username").focus() 
//]]> 
</script> 

    </div> 
</body> 

</html> 

這裏出了什麼問題?如果有人幫忙,那會很棒!

感謝提前:)

回答

2

正如你可以從輸出中看到,通過大本營網站的登錄需要的不僅僅是用戶名和密碼等等。

它至少需要

  • authenticity_token=H5w/7j9I5s38oQ9NdVgpkp/QCxIZ3YW+qM/+Hj/ERr0=

但是,這將是您每次訪問頁面時不同。

看來還可能需要包括

  • product=basecamp
  • subdomain=mobme

你的目的是這個? 你是否試圖屏蔽該網站?

我建議你應該只是仰望開發者API http://developer.37signals.com/

或者如果你沒有足夠的,嘗試MechanizeRubyPerl。 這創建了一個簡單的腳本化機器人,它載入一個頁面並與之交互,因此您不必擔心僞造正確的參數。