Getting Facebook Public Profile URLs - ruby-on-rails

I'm building a feature in my web service to let people enter their Facebook URL into a field. Because few people know their FB user names or public profile URLs, I'd like to provide an interface to assist.
In brief: is there a way to get a list of matching users's public URLs by providing a name alone?
I have tried examining the Facebook Open Graph API; this appears to require knowing the user ID of the person, or the user ID.
I have tried using Mechanize and Nokogiri to automate the process, logging into Facebook as myself and accessing the search feature (http://facebooks.com/search/results.php?q=Person%20Name), but it's not returning any data when attempted this way. I suspect Facebook is using some kind of joojoo to keep me out that way.
Anyone have any suggestions?

With a valid access token, you should be able to query https://graph.facebook.com/me/ to get their ID, name, and public URL (Here's an example using the Graph API Explorer).

There's a search endpoint in the graph API, unfortunately it requires valid user access token.
https://graph.facebook.com/search?q=<name>&type=user&access_token=<user access token>
However it could be yours even, by getting a long living access token it would work for 60 at most, but it's probably a bad idea.
The type could be user, post, event, group, page.

Having done additional research, it appears to not be possible to get a user's public profile page without their permission. Hooray for Facebook privacy settings, I guess.
However, getting an access token is easier than I imagined it would be. Facebook offers an example on their site for getting user permission to access their account, implemented entirely on the client side. Nice and easy; the access token is returned in the URL.
The only downside here is you have to create an application on Facebook, at http://developers.facebook.com/apps. For my purposes, the "Website with Facebook Login" was the application type.
From that point, you can use that token to interrogate the Graph API with ease, as both Warpling and complex857 have suggested.

Related

Can I get a user's display name from Apple MusicKit?

I've been going through Apple's (awful) documentation for both MusicKit, the API and MusicKit JS, but I haven't been able to find an endpoint or method to retrieve a user's display name, email or any other information that I can use to identify the user.
Is there even a way to retrieve this?
I've been having the same issues as well. As far as I can tell, there is no way to identify the user. I'm getting around this by just giving users temporary sessions that get destroyed when they clear their cookies or unauthorize from musickit.
On the other hand, you could ask the user to log in with some other auth provider like google, github etc, and then authorize their apple music after that. Its's not the best user experience to log in to two things in a row, but I guess we have to make do

how to get facebook user id or user name with email id

I am developing a MVC project where I am trying to get the user id or user name from the facebook by using the email id provided by the user,
actually i want to fetch the photo of the user, which can be done using
graph.facebook.com/user_id|user_name/picture
where as i have only have the user email id.
with a little surfing on net i found that user name or user id can be fetched by using
graph.facebook.com/search?q=emailAddress&type=user&access_token=ACCESSTOKEN
but i was not able to get the access_token.
Also referred
developer facebook page
and also this
Any help or direction to work will help indeed.
Basically i understand that i need a access token to get the details.
So how do i do this in my MVC application
As you can read in the Search API docs, you can only search for Users by name, but not by E-Mail. It may have been possible in the past, but it is definitely not possible anymore.
Also, for searching by name, you need to use a User Access Token. You only get one by authorizing a User: https://developers.facebook.com/docs/facebook-login

A Twitter application with only two users

I'm making a Twitter application that makes one Twitter account echo another.
I used the http://dev.twitter.com tool to obtain the access token associate with one account, but since only one person can administer a Twitter application I can't get an access token for any other accounts.
It would appear I have to build an entire 3-legged-oauth strategy only to get one access token!
https://dev.twitter.com/docs/auth/obtaining-access-tokens
How can I most easily acquire an access token for the other user? I don't need a strategy to get many of them, just one.
Okay so I found the answer after a few hours of searching.
You can do it fastest using the PIN auth method and you'll never have to do it again.
Additionally, this gist contains some awesome Ruby code so I didn't have to do any coding, and I got my access token right from the command line:
https://gist.github.com/mirakui/388067
Cheers.

Persistent server side Facebook authentication

I am trying to pull a public feed from the graph onto my site. I'm currently doing this with the Koala gem for Ruby on Rails.
My problem is that I can not figure out if it is possible to silently maintain authentication so as not to interrupt service. I do not want my user to be authenticated, just myself using a server side connection.
Can this be done? What am I missing?
I assume you have a Facebook app set up. To get a public page's posts, you will need to use your app access token. Note that this is different from the app id and secret specified in your app configuration on Facebook's developer site. Koala's OAuth class provides a method to get it.
Here's how to do it:
oauth = Koala::Facebook::OAuth.new Facebook::APP_ID, Facebook::SECRET
app_access_token = oauth.get_app_access_token
graph = Koala::Facebook::API.new app_access_token
graph.get_connections("depechemode", "posts")
(I'm a Depeche Mode fan.)
Do you mean, you want to pull a public page's feed and display it on your website, without your website's users needing to login to facebook? Please provide more detail.

Twitterizer: what is the workflow in order to publish messages on user's profile?

as I started to work with Twitterizer in order to publish on someone's wall I am in confusing time.
There is a page, my case, DefaultTwitter.aspx where is link to authenticate on twitter with token provided. Goes on Twitter and comes back to CallbackTwitter.aspx with outh_token and secret. And so the user is identified. On twitterizer example says:
Step 5 - Store the results
You should now store the access token and the user details. Keep in mind that the
only way an access token will become invalid is if the user revokes access by logging
into Twitter. Otherwise, those values will grant you access to that user's data
forever.
My questions are: - should I store any data in SQL datatable and what exactly(however I hope that is not the case to do so)
somebody said that I should save in a cookie(I thought in session); however then if another user comes then how should I create a button to logout or something like that?
-how will user revoke application access if he would like so?
A live example will be much appreciated as I could not found any on internet how exactly twitter api works.
When your application finishes getting authorization to access the user's data, the result is the access token (represented by 2 values, a key and a secret). Those values are, in effect, the username/password you can use in requests to the API on behalf of that user.* Save those values in your SQL database. You'll also be given the user id and screen name. It's probably a good idea to keep those handy, too.
The user can revoke access to an application by going to http://twitter.com/settings/applications, finding the application and clicking the revoke access button next to it. Your application cannot revoke access for the user.
You asked for an example, but you're citing the example application. Just look at the source code in that sample.
* - That's a simplification for explanation sake. Please don't crucify me, OAuth experts.

Resources