Ask how this JS data is decoded

Source: Internet
Author: User
Ask how this JS data is decoded,
Ask how this JS data is decoded,

Data address: Http://list.taobao.com/itemlist/default.htm?_input_charset=utf-8&json=on&cat=0&style=grid &pcat=food2011&q=ps&rr=1&spm=a2106.m5221.1000187.1&commend=all&psize=95&_ksts= 1382516137021_144&callback=jsonp145


First of all, it's not working with PHP Json_decode.

Share to:


------Solution--------------------
This is JSONP, give you javascript call, use jquery Jsonp way request, own Baidu Bar, or write a
The principle is that the URL inside the callback parameter is your pre-defined function name




JS Bin







If you want PHP to request this link, remove the callback parameter

------Solution--------------------
$url = ' Http://list.taobao.com/itemlist/default.htm?_input_charset=utf-8&json=on&cat=0&style=grid &pcat=food2011&q=ps&rr=1&spm=a2106.m5221.1000187.1&commend=all&psize=95&_ksts= 1382516137021_144&callback=jsonp145 ';
$s = file_get_contents ($url);
Preg_match ('/{.+}/s ', $s, $r); He returns the JS function, so it needs to be bracketed.
$o = Json_decode (Iconv (' GBK ', ' utf-8 ', $r [0]), true);//His data is GBK, but Json_decode can only handle utf-8 functions
Print_r ($o);
Array
(
[Status] = Array
(
[Code] = 200
[url] = =
)

[crumb] = = Array
(
[Marketinfo] = = Array
(
[DisplayName] = ALL markets
[Markethref] = http://list.taobao.com/cat-0.htm
)

[Catpathlist] = = Array
(
)

)

[keyword] = = Array
(
[Key] = Q
[Value] = PS
)

[Sort2list] =
[Promotion] = = Array
.....
  • 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.