Getting friend user id, and their photos - facebook

I am doing some research into the capacity of Facebook Connect. I have some questions on how a couple of bits of functionality.
Is it possible to fetch a list of all friends of a user?
The idea of this is that a user would log in using my site and then they could search through their friends and select one, and the site would get that friends users id and store it to the sites database.
Getting a photos from that user
After getting the friends user id, would it then be possible to get their photos? Or would the friend need to give the site permission to do that?
I am looking into a site where you can buy a greetings card for a friend, and i wanted to know whether my users would be able to login via facebook, pick a friend, get a photo and then at the time of their birthday it would send them a private message (which i think i know how to do) linking them back to my site where they could view the birthday card and their photo.
Thanks

To answer your questions:
Yes. Once you have an access token from the login process for a user, make a Graph API request to https://graph.facebook.com/me/friends. You can test this for yourself here: https://developers.facebook.com/tools/explorer?method=GET&path=me%2Ffriends
Yes. During the login process, you must request user_photos and friends_photos permissions after which you can use the access token for a Graph API request to https://graph.facebook.com/USERID/photos. This will only return those photos for a friend which the user is allowed to see for the current privacy settings.

Related

Facebook GRAPH API - user's friends list does not return any data except total count

I created several test users in my App in Facebook developer account and granted all of them user_friends permission and also connected them together through 'Manage user's Facebook friends' option. However when I try to retrieve one of those user's friends list, it returns only total count of friend, but not their data .. Does anyone know why is that happening ? Thank you in advance..
Test users list
me/friends request and response
Granted permissions to test users
Its a known bug of Facebook which has been reported here for app type Consumer/Business.
https://developers.facebook.com/support/bugs/721152122632278/
https://developers.facebook.com/support/bugs/615773773588521/
But you won't have any issue if your app time is Gaming Service, or you create a test app of your main app but don't forgot to create test users, assign them 'user_friend' permission and add them as a friend with each other. I followed the same process after going through alot of research and finally it worked.

Accessing Friends List on new FB APIs for non-app users

I am building an app where users can send picture messages to friends and would like users to see their Facebook friends list when they login through FB. However, I am confused by Facebook's new API information regarding the access that an app can have to display someone's list of friends. On the FB change log information page it says:
1) Friend list is no longer part of the default permission set and has its own permission: Asking for access to a person's friend list is now a separate permission that your app must request. The new permission is called user_friends.
2) Friend list now only returns friends who also use your app: The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
https://developers.facebook.com/docs/apps/changelog
Does this mean that my app will only display to users their Friends that are also using my app? Is there no way for a User to see their entire friends list? And if not, how can I prompt the User to invite new friends to use my app?
Thanks.
Yes, that is exactly what it means, and for what you want to do there is no way to get the friends who did not authorize your App. But maybe you want to use the Send Dialog instead: https://developers.facebook.com/docs/sharing/reference/send-dialog
For that, you don't even need to authorize the user and he can choose the receiver on his own.

Restrict facebook app from accessing user's friends list

I am using facebook to login to my website. The website does not need any information about the facebook user's friends' list. I am interested only in the user's general information.
https://developers.facebook.com/docs/reference/login/public-profile-and-friend-list/ shows the friend list also as the minimum information shared by Facebook.
Hence wanted to check if there is any way to restrict the user friend list information from being passed on from facebook to my application?
No, when a user authorize an application the minimum data shared is it's basic information and friend list.
Unfortunately you cannot change this.
Official documentation:
When someone connects with an app using Facebook Login, the app can
access their public profile and friend list, the pieces of information
that are visible to everyone. Each other piece of information that
someone adds to their Facebook profile is secured behind permissions.
Source: Facebook

Post on a company facebook page wall on behalf of a user

I have a wp7 app that connect with facebook and lets assume i have the users access token
I am wondering if it is possible to write on the wall of some company facebook page as the user. (i have no ownership of the facebook page and not affiliated with it in any way)
If it is, do you know which permission do i need to obtain ? would love to get any kind of code snippet or a direction i should follow.
Thanks.
it's not possible to write on the wall on behave of the user. You always get a token in the context of a Facebook application - so it will be the app posting on the wall, not the user. And the maximum permission app can ask a user for is publish_stream which allows you (your app actually) to:
Enables your app to post content, comments, and likes to a user's
stream and to the streams of the user's friends.
so in order to post to the company wall, you need to:
Request publish_stream permission from the user
Issue a post request to https://graph.facebook.com/<>/feed url with your message
It's really easy to test. Go to https://developers.facebook.com/tools/explorer, click on "Get access token", select "publish_stream" permission in "Extended" tab, set action to POST, enter "LGUSA/feed" into URL field, click on "Add a field", enter "message: test" and click POST. You will get ID of your post back. See screenshot attached
Sorry this is going to be a bit vauge, but here goes:
First the user is going to have to be authenticated to facebook. There is a good example here. This will give you an authentication tolken to allow you to interact with the API.
The user is going to need facebook permissions to write to the wall. Facebook permissions are described here. I don't know about the specifics of your problem, but with more details I may be able to help more.
then you shoud be able to post to the appropiate wall using the facebook graph api (you'll probably need to be signed up to facebook with a developer account to get to this page).

How to get user's facebook pages and apps list after authentication?

After a user install my application to his/her facebook page,I want to get his/her facebook pages and apps list.
I have read these documents:
http://developers.facebook.com/docs/reference/fql/application/
http://developers.facebook.com/docs/reference/fql/developer/
What is the best way to do?
Another question:
How to check if a user is my app's user?
It sounds like you haven't really looked at the documentation, but they are fairly clear questions, so...
After getting the user_likes permission you can query /me/likes to get a list of pages the user likes. A list of apps is not currently possible in the same way.
A call to /me/permissions or /me/?fields=installed will show if the current app is installed by the current user
A call to /me/accounts with the 'manage_pages' permission will show which pages and apps a user admins, but not which pages and apps they use.
You can use FQL to query this information.
select uid, name, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1
The user needs to allow (and be user of) your app in order to be able to authenticate though oauth.
You can list the user's pages and apps by accessing:
https://graph.facebook.com/me/accounts
or
https://graph.facebook.com/%user_id%/accounts
But you must also provide the user oauth token.