Twitter API 不会使用 php 显示用户名或个人资料图像


Twitter API wont show username or profile images using php

我正在尝试使用Twitter API来显示某个区域的最新推文。 代码排序有效并显示消息,发布推文时的时间戳以及用于制作推文的内容。 但是,我想显示个人资料图像和发布它们的人的用户名。 但是我不断收到名称和个人资料图像的以下错误:

注意:未定义的索引:第 40 行get_tweets.php

以下是请求推文的网页的链接:https://dl.dropboxusercontent.com/u/22591742/get_tweets.php

以及指向我正在使用的 API 的链接:https://dl.dropboxusercontent.com/u/22591742/TwitterAPIExchange.php

提前感谢!

-菲 利 普

您尝试访问的某些属性嵌套在用户数组中。

因此,profile_image_url和名称都在用户数组中。

您应该像这样引用它们:

$status["user"]["profile_image_url"]

因此,对于从$status输出详细信息的代码行

echo("<p>". $status["user"]["profile_image_url"] . $status["user"]["name"] . "<b>Created at:  </b>". $status["created_at"] . "<br/>". $status["source"] . "<br/>" . $status["text"] . "</p>");