Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweet#profile_image_url_https returning nil #340

Closed
pruett opened this issue Jan 5, 2013 · 2 comments
Closed

Tweet#profile_image_url_https returning nil #340

pruett opened this issue Jan 5, 2013 · 2 comments

Comments

@pruett
Copy link

pruett commented Jan 5, 2013

A tweet (returned from Twitter.search) shows the following:

#<Twitter::Tweet:0x007fd92aaa85b0 @attrs={:metadata=>{:result_type=>"recent", :iso_language_code=>"en"}, :created_at=>"Fri Jan 04 20:49:53 +0000 2013", :id=>287299837349728256, :id_str=>"287299837349728256", :text=>"Visit @JaguarUSA #FTYPE Community for news, photos &amp; #CaptureAJag! Win a drive with the all new #FTYPE. http://t.co/igB9MXXY via @jaguarusa", :source=>"<a href=\"http://twitter.com/tweetbutton\" rel=\"nofollow\">Tweet Button</a>", :truncated=>false, :in_reply_to_status_id=>nil, :in_reply_to_status_id_str=>nil, :in_reply_to_user_id=>nil, :in_reply_to_user_id_str=>nil, :in_reply_to_screen_name=>nil, :user=>{:id=>35961348, :id_str=>"35961348", :name=>"Evisu", :screen_name=>"EezyV", :location=>"", :description=>"|Activist|Thinker| Analyst @CarrotCreative|Fashion Aficionado| Loves Music and Television..... ", :url=>"http://www.everaldphillip.com", :entities=>{:url=>{:urls=>[{:url=>"http://www.everaldphillip.com", :expanded_url=>nil, :indices=>[0, 29]}]}, :description=>{:urls=>[]}}, :protected=>false, :followers_count=>403, :friends_count=>473, :listed_count=>15, :created_at=>"Tue Apr 28 02:40:51 +0000 2009", :favourites_count=>180, :utc_offset=>-18000, :time_zone=>"Eastern Time (US & Canada)", :geo_enabled=>true, :verified=>false, :statuses_count=>15502, :lang=>"en", :contributors_enabled=>false, :is_translator=>false, :profile_background_color=>"88CC44", :profile_background_image_url=>"http://a0.twimg.com/profile_background_images/653323083/lc8slpo98etww2vy2gop.jpeg", :profile_background_image_url_https=>"https://si0.twimg.com/profile_background_images/653323083/lc8slpo98etww2vy2gop.jpeg", :profile_background_tile=>false, :profile_image_url=>"http://a0.twimg.com/profile_images/2403040988/v0j5mhqh7y19oxggsyul_normal.jpeg", :profile_image_url_https=>"https://si0.twimg.com/profile_images/2403040988/v0j5mhqh7y19oxggsyul_normal.jpeg", :profile_link_color=>"FFA230", :profile_sidebar_border_color=>"EEEEEE", :profile_sidebar_fill_color=>"EFEFEF", :profile_text_color=>"333333", :profile_use_background_image=>true, :default_profile=>false, :default_profile_image=>false, :following=>nil, :follow_request_sent=>nil, :notifications=>nil}, :geo=>nil, :coordinates=>nil, :place=>nil, :contributors=>nil, :retweet_count=>0, :entities=>{:hashtags=>[{:text=>"FTYPE", :indices=>[17, 23]}, {:text=>"CaptureAJag", :indices=>[57, 69]}, {:text=>"FTYPE", :indices=>[100, 106]}], :urls=>[{:url=>"http://t.co/igB9MXXY", :expanded_url=>"http://ftypecommunity.com", :display_url=>"ftypecommunity.com", :indices=>[108, 128]}], :user_mentions=>[{:screen_name=>"JaguarUSA", :name=>"Jaguar USA", :id=>309066576, :id_str=>"309066576", :indices=>[6, 16]}, {:screen_name=>"JaguarUSA", :name=>"Jaguar USA", :id=>309066576, :id_str=>"309066576", :indices=>[133, 143]}]}, :favorited=>false, :retweeted=>false, :possibly_sensitive=>false}>

Even though it's showing an attribute for profile_image_url_https, when I call p Tweet#profile_image_url_https, for instance, it returns nil. This only seems to happen with certain attributes, while others like text work, for example.

Am I calling this particular attribute wrong? I tried calling #entities but it indicated that its protected.

@sferik
Copy link
Owner

sferik commented Jan 5, 2013

The profile_image_url_https attribute actually exists on the User, not the Tweet itself. Not sure why this is defined as an attribute instead of a delegator. I'll make this change. Thanks for reporting the bug.

In the mean time, you should be able to call:

Twitter.search("query").results.map do |tweet|
  tweet.user.profile_image_url_https
end

@sferik sferik closed this as completed Jan 5, 2013
@pruett
Copy link
Author

pruett commented Jan 5, 2013

perfect, thanks so much

sferik added a commit that referenced this issue Jan 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants