TWTRTweetView not loading profile image

时间:2016-08-31 17:59:47

标签: ios twitter-fabric

I'm loading a tweet from a server. The Tweet json is coming through correctly and has all the correct fields such as

"profile_background_color" = C0DEED;
"profile_background_image_url" = "http://abs.twimg.com/images/themes/theme1/bg.png";
"profile_background_image_url_https" = "https://abs.twimg.com/images/themes/theme1/bg.png";
"profile_background_tile" = 0;
"profile_image_url" = "http://pbs.twimg.com/profile_images/blahblahb/blahblah.jpg";
"profile_image_url_https" = "https://pbs.twimg.com/profile_images/blahblahblah/blahblah.jpg";
"profile_link_color" = 0084B4;
"profile_sidebar_border_color" = C0DEED;
"profile_sidebar_fill_color" = DDEEF6;
"profile_text_color" = 333333;
"profile_use_background_image" = 1;

I do

TWTRTweet* t = [[TWTRTweet alloc] initWithJSONDictionary:tweetDict];
[_tweetView configureWithTweet:t];

And everything displays correctly except the profile image. It's just a blank gray rectangle.

1 个答案:

答案 0 :(得分:2)

Turns out you need to be logged in to load the profile images. I'm guessing that most people load the tweets directly from the twitter api and are already authenticated so it's not a big problem. I'm using the twitter api in a server to cache and serve tweets to my iOS clients, so the clients weren't authenticated. The fix was putting the following in my app delegate

import <TwitterKit/TwitterKit.h>

//in app:didFinishLaunchingWithOptions:
[[Twitter sharedInstance] startWithConsumerKey:@"****" consumerSecret:@"****"];