PHP Use Curl post garbled Taobao phone Curl Note cookie cannot be delivered

Source: Internet
Author: User
1. Error 1 Write the cookie to the header

$header [] = "COOKIE:THW=CN; cna=jxdodv2wcticaxhw0r1cji0v; T=E41C38CB9CE34BD54CA0F9127FD0C6C2; _m_h5_tk=f32d95cc18037cc4e85986f30bc1b896_1439816860045; _m_h5_tk_enc=4c378ef9a2bd15c36fe298e4d97f2c75; ISG=6F159112174B9D2A7534037C941BACB9; L=AHUVQE19SZY/EZ2OB2QU7YA-BRVPESKK; mt=ci=95_1&cyk=6_0; uc3=nk2=tynhu8harvy%3d&id2=uojvefkwbp4upq%3d%3d&vt3=f8dasm73buqroniccbg%3d&lg2=urm48syiivrska%3d% ; LGC=%5CU81F4%5CU96C5%5CU5BB6%5CU88C5; TRACKNICK=%5CU81F4%5CU96C5%5CU5BB6%5CU88C5; _cc_=wqg3dmc9ea%3d%3d; tg=0; wapfdfdtgfg=%2b4drjm5djseckyo4jwyfyq%3d%3d; inezing_session=hz74ozcbreopukkmvnxi8zie_143981251297240bq_2; v=0;

cookie2=1c2f5b3c1b855ca7348e9e4ca4148593 ";


$cookie _jar = dirname (__file__). " /pic.cookie ";
Save cookies
curl_setopt ($curl, Curlopt_cookiejar, $cookie _jar);
curl_setopt ($curl, Curlopt_cookiefile, $cookie _jar);



That's right

2 Error 2 put gzip in the header file (copy from Firebug)

$header [] = "accept-encoding:gzip, deflate";
Correct $header[] = "Accept-encoding:deflate";


3 Error 3, code not uniform

That's right

$header [] = "content-type:application/x-www-form-urlencoded; Charset=utf-8 ";
---------------------------------


$header [0] = "accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$header [] = "content-type:application/x-www-form-urlencoded; Charset=utf-8 ";
$header [] = "accept-encoding:gzip, deflate";
$header [] = "accept-encoding:deflate";
$header [] = "accept-language:zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3";
$header [] = "cache-control:max-age=0";
$header [] = "connection:keep-alive";
$header [] = "host:api.m.taobao.com";
$header [] = "user-agent:mozilla/5.0 (Windows NT 6.1; rv:39.0) gecko/20100101 firefox/39.0 ";
$header [] = "x-firelogger:1.3";


$header = Array ();
$header = Array (
"Content-type:application/x-www-form-urlencoded;
Charset=utf-8 "
);
$header = Array ();
$header [] = "content-type:application/x-www-form-urlencoded;
Charset=utf-8 ";

if (!is_null ($proxy)) {curl_setopt ($curl, Curlopt_proxy, $proxy);}
echo "\ncurl:". $url. " \ n ";
curl_setopt ($curl, Curlopt_url, $thisurl);
curl_setopt ($curl, Curlopt_useragent, ' mozilla/5.0 (Windows NT 6.1; rv:39.0) gecko/20100101 firefox/39.0 ');
googlebot/2.1 (+http://www.google.com/bot.html) This can't be.
curl_setopt ($curl, Curlopt_httpheader, $header);
curl_setopt ($curl, Curlopt_referer, ' http://shop.m.taobao.com/shop/shop_index.htm?spm=0.0.0.0&shop_id= 112980512 ');
curl_setopt ($curl, curlopt_encoding, ' gzip,deflate ');
curl_setopt ($curl, Curlopt_autoreferer, true);
curl_setopt ($curl, curlopt_followlocation, true);
curl_setopt ($curl, Curlopt_timeout, 10);

$cookie _jar = dirname (__file__). " /pic.cookie ";
Save cookies
curl_setopt ($curl, Curlopt_cookiejar, $cookie _jar);
curl_setopt ($curl, Curlopt_cookiefile, $cookie _jar);



------------------------------------------------

Curl corresponding cookie file, saved with Firebug Cookie as is also this format

. taobao.com True/false 1440424369 _m_h5_tk 33e31638cebf21c7da7e1317268de2de_1439823175070
. taobao.com True/false 1440424370 _m_h5_tk_enc db32837cf0f1244e04d777f332766b54

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

  • 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.