简体   繁体   中英

Twitter API wont show username or profile images using php

I am trying to use a twitter API to display the latest tweets in an area. the code sort of works and shows the message, timestamp when the tweet was posted and what was used to make it. however, I want to show the profile images and usernames of the people that posted them. but I keep getting the following error for both name and profile image:

Notice: Undefined index: get_tweets.php on line 40

here is the link for the web page that requests the tweets: https://dl.dropboxusercontent.com/u/22591742/get_tweets.php

and the link to the API that I'm using: https://dl.dropboxusercontent.com/u/22591742/TwitterAPIExchange.php

thanks in advance!

-Filip

Some of the properties you're trying to access are nested within the user array.

So profile_image_url and name are both within the user array.

You should reference them like so:

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

So for the line of your code where you're outputting the details from $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>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM