Android: How to get facebook user image using access_token - android

I am working on an application that need to login with facebook. This is the first time when i am integrating Fb API in my application. I have start from Getting Started with the Facebook SDK for Android & successfully get fb access_token. There are three Activitie in my application & what i need to manage is to have logged in user's Profile Image & name on all these Activities when user successfully get login using facebook.I know, i can query fb GraphAPI & get complete profile data of current logged-in user using access_token. I succeed to get profile data of user by using valid access_token using_https://graph.facebook.com/me?<access_token>&format=json I need the profile image of login user as well(which need user's fb_id)http://graph.facebook.com/<fb_id>/picture?type=largeIs it possible to get user's profile image using access_token?

Finally, after a long search, i got the way to access login user's image by using only access_token
https://graph.facebook.com/me/picture?access_token=<your_access_token_here> thanks to #Jess for your valuable answer!

You don't need an access token to retrieve a user's profile image. Just issue a http GET request on http://graph.facebook.com/YOUR_ID_HERE/picture, so for example:
http://graph.facebook.com/4/picture gets you user id 4's picture, no access token needed.
EDIT:
To fetch the picture without knowing their fb id but with their access token, just execute a GET request on /me?fields=name,picture and you will receive a response with the URL to their profile picture.
See Graph API Tool example:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Dname%2Cpicture

So after messing around with the facebook graph apis for a bit, I have found that you can get the profile pic in two ways:
Use this as the profile pic url by substituting the user id:
https://graph.facebook.com/USER_ID/picture?return_ssl_resources=1
Using the access token:
https://graph.facebook.com/me/picture?access_token=ACCESS_TOKEN
Hope this is helpful.

Related

Unable to get a link to app user's Facebook Home page [duplicate]

I have facebook user ID's
using this id's am accessing profile page of that particular user id.
link will be look like https://www.facebook.com/100001533612613
this link not working now.
https://facebook.com/zuck
https://www.facebook.com/100001533612613 (**not working**)
https://www.facebook.com/profile.php?id=100001533612613 (**not working**)
https://m.facebook.com/ChrisHughes
how can i see profile using UserId
how can i access profile using UserId
You can’t, because you are not supposed to any more …
You will now need to ask for the user_link permission first, and then you can request a (temporary) link to their profile via the link field.
https://developers.facebook.com/docs/graph-api/changelog/version3.0#login

Uploading to a album of a page on Facebook using Android sdk

Say i am the owner of the page "ABC" and there is an album on that page, called "XYZ" and this app is only for one person, me.
I want to upload a picture to "XYZ".
So first thing i need to do is login using the Facebook account who owns the page.
Second i need publish_pages permission? Is that so? How do i get the permissions. And once i get the permissions, how do i post the picture to that album? Can anyone tell me how to do this ?
You need manage_pages and publish_pages
You need to use a Page Token of that Page
Use the /album/photos endpoint to post a photo: https://developers.facebook.com/docs/graph-api/reference/v3.3/album/photos#publish
Additional information about the Graph API in general and login: https://developers.facebook.com/docs/graph-api/using-graph-api

Google Smartlock is not showing Facebook profile picture when the credentials are requested

I have recently integrated google smartlock with my app. Currently, I am trying to save FB credentials with the following code.
Credential.Builder builder =new Credential.Builder(user.getEmail()) //FB Email
.setAccountType(accountType) //IdentityProviders.FACEBOOK
.setProfilePictureUri(uri); // Facebook graph image url
// with host graph.facebook.com
When I request the credential from the smartlock , I am not able to see user image associated with user FB profile account on the dialog that appears asking user to select the account to login in the App. One thing I have observed that if I use static url like below then it is working fine .
https://www.cleverfiles.com/howto/wp-content/uploads/2016/08/mini.jpg
But If I use dynamic url like the one below which needs url redirection then it is not working.
https://graph.facebook.com/XXXXXXXXXX/picture?height=200&width=200&return_ssl_resources=true
Does anyone facing the same issue ?
This is a known bug in Play Services not handling the redirect correctly, it's on the backlog to get fixed, sorry about that.

FirebaseAuth android get Facebook friends list

I use facebook login in my app. Once the users are logged-in I can get their basic facebook info such as display name, email, and phot url.
I'd like to get their facebook friends list. I think I can get it "directly" with firebase but I don't remember how and I cannot find any info about it. I think I first have to tell Firebase to get friends list when people login with facebook, then I sould be able to get it with a method such as firebaseAuth.getCurrentUser().getFriendList().
Do you know how to get facebook friends list with firebaseAuth ?
Thank you,
Alex
It is feasible, but only the friends that also use your app. The trick is to add a scope to your login method. In Angular it looks like this
this.afAuth.auth.signInWithPopup(new firebase.auth.FacebookAuthProvider().addScope('user_friends'))
That scope at the end is the trick. Then, you need at least two users that are friends on facebook to login. You will note the popup is different as it now asks permission for the user's friends.
The response will include an access token. Then you can use that token to request the user's friends that are also using the app with a GET request like this
https://graph.facebook.com/v2.11/{facebook_uid}/?fields=friends{name,id}&access_token={access_token}
Note I'm using a particular version, but you should change that to whatever you need.
generally obtaining user's all friends list from Facebook is not possible, they removed this option years ago, with API v2.0 introduction... more info about and useful suggestions HERE
there is an official FB API called Graph API and HERE you have some doc about friend lists
and the Firebase... well, this is Google's product and it have nothing to do with Facebook... You are probably using FB mail address for creating an account in Firebase service/database, but it is keeping only this data plus some additional attributes if set (like photo or visible name).
firebaseAuth.getCurrentUser() returns FirebaseUser object, which have THESE methods - like you see: logpass, name, photo url and only few more methods. no option for getting friends list, because there is no method to set them, and no possibility to get this list from FB lib/API

How to get a friends user wall from facebook?

I want to read my friends posts (feeds?, all posts but for a specific user only) from his user wall.
I need all (posts, feeds, statuses) that i see when i look at his page directly from the website.
I use the android sdk and i tried the graph api and rest method.
My app is registered and i have logged in facebook to get the access token (permission: read_stream)
but i dont get that infos that want to.
Please help.
Thx.
How about testing your Graph API call in the Graph API Explorer?
https://developers.facebook.com/tools/explorer/
In my case, I could get my first 10 friends' feed (wall) with the url https://graph.facebook.com/me?fields=friends.limit(10).fields(feed)
Note that I used field expansion of the Graph API.
http://developers.facebook.com/docs/reference/api/field_expansion/
You need them to actually use your app and grant full permissions via the graph API.
You cannot simply 'grab a friends wall'. You must do that via your app and it needs the permissions to do so from the user in question.

Categories

Resources