propublica / politwoops_sunlight

Politwoops web front end
Other
44 stars 30 forks source link

Twitter API v1.1 #6

Closed AxGa closed 11 years ago

AxGa commented 11 years ago

Hi guys,

The updated twitter gems that you uploaded will fix the issues with politicians profile pics or I have to change also the "profile_image_url" from the database. I now use "http://api.twitter.com/1/users/profile_image?screen_name=...&size=bigger" Thank you in advance.

dvogel commented 11 years ago

The new user endpoint requires authentication. I'll push a fix tomorrow.

dvogel commented 11 years ago

Commit 57742c9daa326 should fix this. You'll have to add twitter app authentication tokens to config.yml.

AxGa commented 11 years ago

Thank you very much! Just another question, what do you use in the "profile_image_url" at the database. I tried "http://api.twitter.com/1.1/users/show.json?screen_name=..." but i get 400 error bad request.

dvogel commented 11 years ago

In v1.1 an account does not have a predictable profile image URL. Instead you must make a /api/1.1/get/users/show request. That will return a URL like http://a0.twimg.com/profile_images/1777569006/image1327396628_normal.png.

AxGa commented 11 years ago

I 'm really sorry to bother you again. I 've tried to make the proper request but I 'm a newbie in python and haven't managed to succeed. I 've seen you fixed this in your site so would it be possible to share the code? Thanks in advance.

dvogel commented 11 years ago

The code for this is shared in this repo. You can see the changes in commits 4db3c7e09b and 57742c9da. After you pull in those commits you can run rake politicians:reset_avatars to get a new avatar URL for each politician in your database.

dvogel commented 11 years ago

I just saw that you mentioned python. The avatars are handled by the rails website. The python code is just for ingestion of tweets and capturing screenshots and linked pictures.