devise-twitter icon indicating copy to clipboard operation
devise-twitter copied to clipboard

How to save twitter data on local db

Open krzkrzkrz opened this issue 14 years ago • 12 comments

Hi, great plugin! And I hope that the development goes on for this gem.

I am wondering. I am able to do a sign-in with Twitter. My db stores twitter_handle, twitter_oauth_token and twitter_oauth_secret. However, my user model also has other fields such as: full_name, description, url, followers_count, friends_count, photo_caption, photo_file_name, etc, which are all fields from the user twitter api (http://dev.twitter.com/doc/get/statuses/show/:id)

I need to populate these fields in my local db. How should this be done?

krzkrzkrz avatar Sep 29 '10 10:09 krzkrzkrz

I think I need to add a callback for that.

MSch avatar Sep 29 '10 10:09 MSch

MSch, can you be more descriptive? :-) Where should the callback be written? Perhaps a quick sample?

That way other devs might find it useful

krzkrzkrz avatar Sep 29 '10 10:09 krzkrzkrz

Well after warden hands devise-twitter all the data, devise-twitter disregards everything but the tokens. This is where I'm going to add the callback.

MSch avatar Sep 29 '10 10:09 MSch

Oh right, ok. Looking forward to it. When can we expect this? :-) Just need a date, so I can start integrating other stuff on my app

krzkrzkrz avatar Sep 29 '10 10:09 krzkrzkrz

Well I wanted to work through the issues soon anyways, so I might as well start today. :)

You've got twitter/email/jabber? May I ask for feedback on some API parts?

MSch avatar Sep 29 '10 10:09 MSch

MSch, oooh so sorry. Im still very new to Ruby/RoR. Previously using PHP/Symfony and relied on my own PHP lib to process Twitter callbacks for data to be saved locally... Code was a bit messy, but it worked.

krzkrzkrz avatar Sep 29 '10 10:09 krzkrzkrz

Never mind then :)

MSch avatar Sep 29 '10 10:09 MSch

By the way, reading your previous comment about the twitter gem. Once a user is saved in the db using devise-twitter. Can't I use the twitter gem (http://twitter.rubyforge.org/) to do a lookup on the user and save data locally?

Maybe a callback from devise-twitter is not needed for this?

krzkrzkrz avatar Sep 29 '10 10:09 krzkrzkrz

Yes, that would work fine, (just see the other issue for how) but you'd incur another request to the Twitter API.

MSch avatar Sep 29 '10 10:09 MSch

Hmm, ahh yea. Another request would occur. Will be looking forward to your callback implementation then

krzkrzkrz avatar Sep 29 '10 10:09 krzkrzkrz

Any updates on this? :-)

krzkrzkrz avatar Sep 30 '10 07:09 krzkrzkrz

MSch, I am trying to fork this and would need to callback method which is needed so I can add/copy the users twitter details onto the local db when he logs on via the app.

Its quite an important aspect in the app...

As such, where would it be appropriate to create such a method? Which file? Your feedback will be appreciated

krzkrzkrz avatar Oct 04 '10 16:10 krzkrzkrz