Can I get and show pictures of users through the Graph API with just the access token application?, for example collect the user information for show it in a same page, of course those users been accepted the permissions of the web app and then other user can access to the web and see the information of all those users. All this only storing the ids of facebook, I mean, for get in the same page the information of the users, I want to make a call through the API and retrieve his information by the facebook ID stored in database.
You can show public data of user using his/her user ID and Application Access token , which include name and profile picture.
https://graph.facebook.com/<user_id>
Submitting a GET HTTP request on above URL with correct user id will give you publicly available data. You can add fields to get more public data like profile photo.
Related
I'm studying how to develop an iOS app and I need to figure out how should I structure it.
Architecture:
I've an external database, a REST api (as interface between the database and the app), and the iOS app.
The question:
I'd like users to authenticate by a simple form or by a Facebook login button but in each case a table 'user' in the database has to be filled with default fields like name, surname, email, profile picture, password(?).
For the standard authentication there are no problem, but for Facebook authentication I'm quite confused about theory:
Should I use access token? How?
When a user get authenticated with Facebook I haven't his password, so how can I get his informations from the database? In the standard way I would give to the database username and password and it would return for example the id field.
Sorry for my english.
You can use the access token of current logged in user
[FBSDKAccessToken currentAccessToken]
and send it to your REST api. From there you can retrieve every information you need and save it to your database (except user's password of course). If a user sign in for first time in your app insert a new user in your database and save user's Facebook User ID.
The whole idea of using authenticate and authorization is not to have access to user's password of another app, but the user authorize (confirm) your app to have access in his/her account with specific permissions.
Here is a step-by-step answer of what you need:
Design for Facebook authentication in an iOS app that also accesses a secured web service
You need to save the currentAccessToken that the login request returns to you.
Then, using Facebook's Graph API, the userID that was returned in the login request, and the user access token, you can request a user object, which has the email address, assuming you added the email permission in the login request.
Also use the Graphi API to retrieve the user's photo using the userID that was returned in the login request:
50x50 pixels
<img src="//graph.facebook.com/{{fid}}/picture">
200 pixels width
<img src="//graph.facebook.com/{{fid}}/picture?type=large">
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
I have a website where users can create an account and log in. This is stored in a database on the server. I also want users to be able to log in with Facebook etc, and thus skip the account creation. I don't know how to combine this and keep it persistent in the database. Any good examples on this use case?
Let's first see how logins work in general. When a user is logging in for the first time, a session id is generated for the user and is stored in the browser of the user as a cookie (note that there are mechanisms to store session id without a cookie, but let's assume you require a cookie for simplicity).
For subsequent requests to other pages in the same website, the cookie is also sent along. With this cookie (which has the session id), the unique user can be identified.
So, all that you require to know to identify a user in the server side (upon a web request) is the session id.
Having said that, if you want to include facebook etc into the login mechanisms, you need to do two things:
Connect your website with facebook (you will require a facebook developer account and some keys. Look here). When you do this successfully, if the user selects facebook login, your website should redirect to facebook login page and once the user logs in into facebook account, facebook will redirect back to your website with a token. This token is an indication that the user is a 'real' user. If required, you can use the token to get more details (such as facebook id, email address, name, etc.) from APIs facebook.
The second step is the same for any authentication flow. You need to generate a session id for use by your server and then save the session id in cookie.
What I have specified is the general flow on how your requirement could be achieved. The mechanics of how to do this will depend on the server side technology that you are adopting (such as ASP.NET, Ruby, etc.)
Additionally, if your website requires storing information about the user behavior / user activity, you may need to additionally check if the user logged in via FB already exists in your database. If not present, you can store the user's facebook id or something to uniquely identify the user later. With this as the primary key / user id, you can store user activity (such as inserting a record in orders table if the user purchases a product).
I am working on asp.net mvc. I am trying to search public facebook posts of a user by the facebook url. i.e. I have a textbox in my webpage in that user will enter his facebook url like https://www.facebook.com/xxx.yyy and based on that url i need to find particular user and needs to display all public posts of that user. I have tried with open graph api like,
https://graph.facebook.com/search?q={username found in url}&type=user
but it asks me accesstoken. I will get accesstoken only when user was login to facebook but i need to display user's public posts without asking him for authentication. Please guide me.
You don't necessarily need a User access token to get result from https://graph.facebook.com/search , you can use your App Access Token to retrieve the result.
You can also use the same App Access Token to query the public post of the user by calling to Facebook's end point like
https://graph.facebook.com/<user-id>/posts
Where is the value specified in your textbox as
https://www.facebook.com/<user-id>
I can get user's friends list. But i`m intresting only in user's friends who authorize my app on my site.
How i can do it?
At the end of an authentication process (with OAuth I guess), Twitter gives you tokens for the application, the ID and the screen name (username) of the user who authorized the app.
So you can do something like this :
At the end of the authentication process : storing the user ID and/or the username of the user who authorized your application (in your database for example).
When you retrieve the user's friend list, you can see if user's friend authorized your app by watching if its ID (and/or its username, depending on what you kept) is in the storage where you keep informations about users who authorized your app.