Alternative way to get username from facebook API*

My site ( using facebook graph for user login. I haven’t maintenance it for the last 2 months. when I try to login few days ago it return an error because the username  from Facebook graph API was empty.

I googled why this is happened. and got that facebook has depecrated the /me/username API. alternatively we can use email as username. but I resist to use facebook username as my application users username. so I do some trick.. seems stupid but it works.

I scrapped the user facebook profile using nokogiri. and get the username value from the meta tag (until facebook remove the username from the html code.. but I think it won’t happen :P). here’s the code in ruby:


Hope it helps, cheers ! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *