Note that there are some explanatory texts on larger screens.

plurals
  1. POLogging Into AliBaba.com programmatically
    text
    copied!<p>I am trying to figure out how to login to the website <a href="https://login.alibaba.com" rel="nofollow noreferrer">https://login.alibaba.com</a> using PHP and CURL. I am using the code below but it does not seem to be working. How would you recommend I login to this site automatically?</p> <p>My current code:</p> <pre><code>&lt;? $cookie = "cookie.txt"; // set global curl options $curloptions = array( CURLOPT_USERAGENT =&gt; '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 =&gt; 60, CURLOPT_COOKIEJAR =&gt; $cookie, CURLOPT_COOKIEFILE =&gt; $cookie, CURLOPT_REFERER =&gt; 'http://www.alibaba.com' ); // set userinfo $username = 'xxxxxxxxxxx'; $password = 'xxxxxxxxxxx'; // clear cookie.txt (fresh session) $handle = fopen($cookie, 'w'); fclose($handle); // make a dummy request to generate a session curl_http_request('https://login.alibaba.com', $curloptions); // login curl_http_request('https://login.alibaba.com', array( CURLOPT_POSTFIELDS =&gt; 'xloginPassport=' . $username . '&amp;xloginPassword=' . $password . '&amp;noCsrfToken=&amp;xloginCheckToken=&amp;rememberme=&amp;runatm=', CURLOPT_POST =&gt; TRUE ), $curloptions ); //example request echo curl_http_request('https://login.alibaba.com', array( CURLOPT_FOLLOWLOCATION =&gt; TRUE, CURLOPT_RETURNTRANSFER =&gt; TRUE ), $curloptions ); function curl_http_request ($url, $moreoptions = array(), $options = array()) { foreach ($moreoptions as $k =&gt; $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; } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload