0

New to PHP, and found a solid code that's able to retrieve JSON data from Twitter API and echo it out. Here's the PHP code that retrieves the user-pic of @Guardian (newspaper)

 <?php
   $data = json_decode(file_get_contents('https://api.twitter.com/1/users/lookup.json?screen_name=guardian'), true);
   echo $data[0]['profile_image_url'];
 ?>

The JSON data for the image is:

profile_image_url":"http://a0.twimg.com/profile_images/1857791844/G_twittermain_normal.jpg"

So obviously it echoes the url (text), i'd like to output the actual image and possibly have control over the sizing of it too if possible.

Thanks in advance!

4

1 に答える 1

1

    <img src=" <?php echo $data[0]['profile_image_url'];?>" />
</body>

于 2012-10-13T09:01:58.203 に答える