I'm using Omniauth-Twitter with Device.
Twitter API gives me
{
"id": 2244994945,
"id_str": "2244994945",
"name": "TwitterDev",
"screen_name": "TwitterDev",
"location": "Internet",
"profile_location": null,
"description": "Developer and Platform Relations @Twitter. We are developer advocates. We can't answer all your questions, but we listen to all of them!",
"url": "http://twitter.com",
"entities": {
"url": {
"urls": [
{
"url": "https://twitter.com",
"expanded_url": "https://dev.twitter.com/",
"display_url": "dev.twitter.com",
"indices": [
0,
23
]
}
]
},
"description": {
"urls": []
}
},
.....
and I need to get the expanded_url for my website field, but it is in kinda array, how do I get that data?
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |designer|
user.provider = auth.provider
user.uid = auth.uid
user.username = auth.info.nickname
user.website = HERE_I_NEED_USERS_WEBISTE_INFO
end
end
adding this to my designer.rb worked!
begin
user.website = Net::HTTP.get_response(URI.parse(auth.info.urls.Website))['location']
rescue
user.website = auth.info.urls.Website
end