PHP Curl Demo Login Get cookie

Source: Internet
Author: User
PHP Curl Demo Login Get cookie Help
Beginners Learn to use PHP curl simulation landing, such as the Weiphon forum with the following code success, landing www.xiaomi.com will not succeed, help AH. I think it's a question of getting a cookie. Trouble the cows to help solve. The sleepless night can not sleep Ah!

$cookie _file=tempnam ('./temp ', ' Cookie ');
$login _url= ' Https://account.xiaomi.com/pass/serviceLoginAuth ';
$post = ' user&pwd=&sid=eshop&callback=http%3a%2f%2forder.xiaomi.com%2flogin%2fcallback%3ffollowup% 3dhttp%253a%252f%252fwww.xiaomi.com%252f%26sign%3dmjk4nmvlyzniowy5ytkwmjexnzg5mjkynze3zmixogm4ytbimdk1mg%2c%2c &_sign=f%2fkb8safmalz0s28kcltbsmzlem%3d&_json=true '//Avoid unnecessary trouble post specific account password removed

$ch = $curl =curl_init ($login _url);
curl_setopt ($ch, curlopt_header,0);
curl_setopt ($ch, curlopt_returntransfer,0);
curl_setopt ($ch, curlopt_post,1);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
curl_setopt ($ch, Curlopt_postfields, $post);
Curl_exec ($ch);
Curl_close ($ch);

$url = "http://www.xiaomi.com/index.php";
$ch =curl_init ($url);
curl_setopt ($ch, curlopt_header,0);
curl_setopt ($ch, curlopt_returntransfer,0);
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file);
$contents =curl_exec ($ch);
Curl_close ($ch);


?>

Share to:


------Solution--------------------
 
  






Account name Error


Please enter your account name









Please enter your password



  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.