Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get "bigger-size" user image with Twitter API 1.1?

Tags:

I'm trying to get last 5 tweets from a person. I did it, but profile picture is not looking normal, resolution is corrupted. like that. ! http://i.hizliresim.com/wLQEJZ.jpg

var $twitter = $('#twitter');      $.getJSON('http://www.demo.net/twitter.php?username=yeniceriozcan&count=5', function(data){         var total = data.length,             i = 0;         $twitter.html(''); // önce içindekini temizle sonra tweetleri yazdır.         for ( i; i < total; i++ ){             var tweet = data[i].text; // tweet             var date = parseTwitterDate(data[i].created_at); // tarih             var image = data[i].user.profile_image_url; // profil resmi             var url = 'https://twitter.com/' + data[i].user.screen_name +'/status/' + data[i].id_str;             $twitter.append('<div class="tweet"><a target="_blank" href="' + url + '"><img src="' + image + '" alt="" class="profile-image" />' + tweet + '</a> <span class="tweet-date">(' + date + ')</span></div>');         }     }); 

This is my code. I tried to that for to get profile picture,

var image = data[i].user.profile_image_url; 

And also in other tweets file,

$tweets = $twitter->get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name='.$username.'&count='.$count);  print json_encode($tweets); 

I used this api.

but I can not view pictures in normal resolutions. How can I fix it? Thanks.

like image 688
user2674354 Avatar asked Jan 31 '14 16:01

user2674354


People also ask

Does Twitter have image size limit?

Photos can be up to 5MB; animated GIFs can be up to 5MB on mobile, and up to 15MB on web. We accept GIF, JPEG, and PNG files.

What is the largest image size for twitter?

Twitter images sizes for in-stream photos: 1600 x 900 pixels (recommended) Maximum file size: Up to 5MB for photos and GIFs on mobile. Up to 15MB on the web.

Why does my twitter feed look bigger?

Twitter is testing new changes to how photos and videos appear on its apps, closer to how images appear on other services such as Instagram. The new feature will expand visual media embedded in tweets to fill the whole width of a mobile phone's screen.


2 Answers

I found that using bigger still brought the picture back in a relatively small format. Using this answer enables you to resize the image allowing you to have a big image without distortion.

If you want to get the image full size just get rid of the "_normal" completely

http://pbs.twimg.com/profile_images/429221067630972918/ABLBUS9o_normal.jpeg 

Goes to

http://pbs.twimg.com/profile_images/429221067630972918/ABLBUS9o.jpeg 

Note: The urls in this answer are modified so as to not reflect my twitter details hence why entering them will give you a "no page exists"

like image 101
sam_smith Avatar answered Nov 13 '22 10:11

sam_smith


When you read the url from data[i].user.profile_image_url, replace "_normal" with "_bigger". Here's the explanation from the Twitter docs:

User Profile Images and Banners

like image 33
Joe Mayo Avatar answered Nov 13 '22 08:11

Joe Mayo