Curl 登录阿里巴巴

Curl 登录阿里巴巴,curl,login,Curl,Login,我试图弄清楚如何使用PHP和CURL登录到该网站。我正在使用下面的代码,但它似乎不起作用。您建议我如何自动登录此网站 我当前的代码: <? $cookie = "cookie.txt"; // set global curl options $curloptions = array( CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070

我试图弄清楚如何使用PHP和CURL登录到该网站。我正在使用下面的代码,但它似乎不起作用。您建议我如何自动登录此网站

我当前的代码:

<?
$cookie = "cookie.txt";
// set global curl options
$curloptions = array(
        CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
        CURLOPT_TIMEOUT => 60,
        CURLOPT_COOKIEJAR => $cookie,
        CURLOPT_COOKIEFILE => $cookie,
        CURLOPT_REFERER => 'http://www.alibaba.com'
);

// set userinfo
$username = 'xxxxxx';
$password = 'xxxxxx';

// clear cookie.txt (fresh session)
$handle = fopen($cookie, 'w');
fclose($handle);

// make a dummy request to generate a session
$response = curl_http_request('https://passport.alibaba.com/mini_login.htm?lang=pt_br&appName=aebuyer&appEntrance=default&cssLink=&styleType=auto&bizParams=&notLoadSsoView=false&notKeepLogin=true&rnd=0.6961233267322033', $curloptions);
preg_match('/name="ua".+?value="([^"]+)"/mis', $response, $matches);
$ua = $matches[1];

// login
curl_http_request('https://passport.alibaba.com/newlogin/login.do?fromSite=4', 
    array(
        CURLOPT_POSTFIELDS => http_build_query(array(
            'ua' => $ua,
            'appName' => $appName,
            'appEntrance' => $appEntrance,
            '_csrf_token' => $_csrf_token,
            'rdsToken' => $rdsToken,
            'cid' => $cid,
            'umidToken' => $umidToken,
            'lang' => $lang,
            'hsid' => $hsid,
            'isRDSReady' => $isRDSReady,
            'isUMIDReady' => $isUMIDReady,
            'umidGetStatusVal' => $umidGetStatusVal,
            'isRequiresHasTimeout' => $isRequiresHasTimeout,
            'loginHost' => $loginHost,
            'scene' => $scene,
            'isMobile' => $isMobile,

            // all input
        )),
        CURLOPT_POST => FALSE
    ), $curloptions
);

//example request

function curl_http_request ($url, $moreoptions = array(), $options = array())
{
    foreach ($moreoptions as $k => $v) $options[$k] = $v;
  $handle = curl_init($url);
  curl_setopt_array($handle, $options);
  ob_start();
  $buffer = curl_exec($handle);
  ob_end_clean();
  curl_close($handle);
  return $buffer;
}
?>

谢谢