Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Twitter json提要中的显示url_Php_Json_Twitter_Rss - Fatal编程技术网

Php 使用Twitter json提要中的显示url

Php 使用Twitter json提要中的显示url,php,json,twitter,rss,Php,Json,Twitter,Rss,我遇到了一个问题,我希望这是一个合理的直截了当的解决方案。我正在使用Thomas Yung的Twitter JSON to RSS,在试图让脚本实际输出display_url变量时遇到了一个问题。我不是PHP高手,但从第85行开始,他们访问twitter_json_to_rss.PHP中各种信息点的方式似乎相当简单 $title= htmlspecialchars(htmlspecialchars_decode($line->user->name.": ".strip_tags($l

我遇到了一个问题,我希望这是一个合理的直截了当的解决方案。我正在使用Thomas Yung的Twitter JSON to RSS,在试图让脚本实际输出display_url变量时遇到了一个问题。我不是PHP高手,但从第85行开始,他们访问twitter_json_to_rss.PHP中各种信息点的方式似乎相当简单

$title= htmlspecialchars(htmlspecialchars_decode($line->user->name.": ".strip_tags($line->text)));
$description= htmlspecialchars(htmlspecialchars_decode(strip_tags($line->text)));
$url = htmlspecialchars("https://twitter.com/".$line->user->screen_name."/statuses/".$line->id_str);;
$image = (strlen($line->entities->media[0]->media_url)>0) ? htmlspecialchars($line->entities->media[0]->media_url) : null;
$created_at = rfc822Date($line->created_at);
现在,基于我在下面介绍的json输出的结构,如何调用变量似乎相当简单。如果我想输出display\uURL,应该像调用$line->entities->url->display\uURL一样简单,但这似乎不起作用。这里有我遗漏的东西吗?似乎我无法从entities部分访问任何内容,但我可以提取JSON中可用的大多数其他变量。是否有一些东西是不允许我从Twitter API或类似的东西访问的?我只是不知道为什么它不起作用

 {
  "created_at":"Sun Mar 16 19:57:47 +0000 2014",
  "id":445287835055439872,
  "id_str":"445287835055439872",
  "text":"93% of Crimeans vote to join Russia, exit polls show http:\/\/t.co\/57teqvKOmB",
  "source":"\u003ca href=\"http:\/\/www.socialflow.com\" rel=\"nofollow\"\u003eSocialFlow\u003c\/a\u003e",
  "truncated":false,
  "in_reply_to_status_id":null,
  "in_reply_to_status_id_str":null,
  "in_reply_to_user_id":null,
  "in_reply_to_user_id_str":null,
  "in_reply_to_screen_name":null,
  "user":{
     "id":972651,
     "id_str":"972651",
     "name":"Mashable",
     "screen_name":"mashable",
     "location":"",
     "description":"News, resources, inspiration and fun for the connected generation. Tweets by @mashable staff.",
     "url":"http:\/\/t.co\/1Gm8aVACKn",
     "entities":{
        "url":{
           "urls":[
              {
                 "url":"http:\/\/t.co\/1Gm8aVACKn",
                 "expanded_url":"http:\/\/mashable.com",
                 "display_url":"mashable.com",
                 "indices":[
                    0,
                    22
                 ]
              }
           ]
        },
        "description":{
           "urls":[

           ]
        }
     },
     "protected":false,
     "followers_count":3870836,
     "friends_count":2740,
     "listed_count":112874,
     "created_at":"Mon Mar 12 01:28:01 +0000 2007",
     "favourites_count":193,
     "utc_offset":-14400,
     "time_zone":"Eastern Time (US & Canada)",
     "geo_enabled":false,
     "verified":true,
     "statuses_count":98940,
     "lang":"en",
     "contributors_enabled":false,
     "is_translator":false,
     "is_translation_enabled":true,
     "profile_background_color":"00AEEF",
     "profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/705312036\/bf7ca2a3f077d7e57b12a5ea4f1db268.png",
     "profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/705312036\/bf7ca2a3f077d7e57b12a5ea4f1db268.png",
     "profile_background_tile":false,
     "profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/3690637553\/5c348fee8afbcefa1978004a864a51ce_normal.png",
     "profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/3690637553\/5c348fee8afbcefa1978004a864a51ce_normal.png",
     "profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/972651\/1369156394",
     "profile_link_color":"00AEEF",
     "profile_sidebar_border_color":"FFFFFF",
     "profile_sidebar_fill_color":"88DBF4",
     "profile_text_color":"3B3B3B",
     "profile_use_background_image":false,
     "default_profile":false,
     "default_profile_image":false,
     "following":false,
     "follow_request_sent":false,
     "notifications":false
  },
  "geo":null,
  "coordinates":null,
  "place":null,
  "contributors":null,
  "retweet_count":74,
  "favorite_count":20,
  "entities":{
     "hashtags":[

     ],
     "symbols":[

     ],
     "urls":[
        {
           "url":"http:\/\/t.co\/57teqvKOmB",
           "expanded_url":"http:\/\/on.mash.to\/1gwwY3W",
           "display_url":"on.mash.to\/1gwwY3W",
           "indices":[
              53,
              75
           ]
        }
     ],
     "user_mentions":[

     ]
  },
  "favorited":false,
  "retweeted":false,
  "possibly_sensitive":false,
  "lang":"en"

},

您的
URL
似乎是一个数组。试试这个-

$line->entities->urls[0]->display_url