远程地址:http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list通过浏览器可以得到,但是通过file_get_contents这个函数却为空,别的还有什么办法?另外得到的数据看着有点像json,但是用json_decode却不能将它转化为数组,求将得到的数据转换数组的方法

解决方案 »

  1.   

    那是js种的json和php的json有点区别,用jQuery获取:$.getJSON("http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list", function(json){
      alert("JSON Data: " + json);
    });
      

  2.   


    我想通过php获取,然后写到html中,用jq获取的,写到html中点击右键查看不到啊!
      

  3.   

    另外给我的这段代码,怎么都弹出不了:我是这样写的:<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
    <script>
    $(function(){
    $.getjson("http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list", function(json){
      alert("JSON Data: " + json);
    });
    })
      

  4.   

    另外给我的这段代码,怎么都弹出不了:我是这样写的:<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
    <script>
    $(function(){
    $.getjson("http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list", function(json){
      alert("JSON Data: " + json);
    });
    })
      

  5.   

    $con= file_get_contents($url);
    $con= preg_replace('/shop_rate_list\((.*)\)/s','$1',$con); 
    print_r(json_decode(iconv('gbk','utf-8',$con),true)); 
    Array
    (
        [watershed] => 100
        [maxPage] => 1
        [currentPageNum] => 1
        [rateListDetail] => Array
            (
                [0] => Array
                    (
                        [XID] => 
                        [append] => 
                        [auction] => Array
                            (
                                [XID] => 
                                [aucNumId] => 10653792806
                                [auctionPrice] => 2168
                                [link] => http://trade.taobao.com/trade/detail/trade_snap.htm?trade_id=180368285769180
                                [sku] => 机身颜色:港版ME860【官网可查 最新3月出厂  现货当天发】&nbsp;&nbsp手机套餐:套餐四
                                [thumbnail] => 
                                [title] => 港版ME860 Motorola/摩托罗拉 MB860/Atrix 4G 如何鉴别翻新机
                            )                    [award] => 
                        [content] => 一般
                        [date] => 2012.06.04
                        [from] => 
                        [photos] => Array
                            (
                            )                    [rate] => 0
                        [rateId] => 18709606527
                        [raterType] => 0
                        [reply] => 
                        [shareInfo] => Array
                            (
                                [XID] => 
                                [lastReplyTime] => 
                                [pic] => 0
                                [reply] => 0
                                [share] => 
                                [userNumIdBase64] => 
                            )                    [spuRatting] => Array
                            (
                            )                    [tag] => 
                        [tradeId] => 180368285769180
                        [useful] => 0
                        [user] => Array
                            (
                                [anony] => 
                                [avatar] => 
                                [displayRatePic] => b_red_2.gif
                                [nick] => 相爱没那么容易8
                                [nickUrl] => http://wow.taobao.com/u/ODM0NTY4MDkx/view/ta_taoshare_list.htm?redirect=fa
                                [rank] => 39
                                [rankUrl] => http://rate.taobao.com/rate.htm?user_id=834568091&rater=1
                                [userId] => 834568091
                                [vip] => 
                                [vipLevel] => 2
                            )                    [validscore] => 1
                    )        ))
      

  6.   


    为什么我的获取不到啊!我是这样写的代码:$url='http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list';
    $con= file_get_contents($url);
    $con= preg_replace('/shop_rate_list\((.*)\)/s','$1',$con); 
    print_r(json_decode(iconv('gbk','utf-8',$con),true)); 
    页面错误提示:
    ( ! ) Notice: Undefined variable: url in E:\wwwroot\post\Untitled-2.php on line 13 
    Call Stack 
    # Time Memory Function Location 
    1 0.0008 366624 {main}( ) ..\Untitled-2.php:0 ( ! ) Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in E:\wwwroot\post\Untitled-2.php on line 13 
    Call Stack 
    # Time Memory Function Location 
    1 0.0008 366624 {main}( ) ..\Untitled-2.php:0 
    2 0.0011 366808 file_get_contents ( ) ..\Untitled-2.php:13 
      

  7.   

    头部加上: error_reporting(E_ALL & ~E_NOTICE);