I'm trying to list all my friend's gender interests, the "Interested in women" for example.
The scope of my token is basic_info, friends_relationship_details, friends_relationships, public_profile, user_friends, user_relationship_details, user_relationships.
The user_relationship_details correctly allowed me to see my own "interested in" field, but friends_relationship_details did not do the same for my friends. They all return null.
Full query in fql is "SELECT uid, name, meeting_for, meeting_sex, relationship_status FROM user WHERE uid='{friend-uid}'"
I have also tried OpenGraph Explorer with my app's access token and interested_in doesn't show up there either.
Why would this be?
update: Even if a friend has interested in privacy as public, my app can't access it.
Related
I'm trying to upload photos to a specific album of the authenticated Facebook user. But the photo does not appear in the album. It appears in a new album named '"appname" Photos'. I'll try to describe my way as complete as possible - maybe this helps you out there to find my mistake.
I'm not using any Facebook or third party SDK. The project programming language is C# (if it matters).
First of course, I'm getting an access token, by sending the user to the following URL:
https://www.facebook.com/dialog/oauth?client_id={0}&redirect_uri={1}&response_type={2}&scope={3}
{0}: The client ID: my application ID, as provided by Facebook
{1}: The redirect URI, set to 'https://www.facebook.com/connect/login_success.html', as I'm working on a desktop application
{2}: The response type: 'token'
{3}: The scope - all the privileges I'm requesting. This is a comma separated list of the following items:
manage_pages
email
user_about_me
user_photos
user_videos
publish_actions
publish_stream
user_likes
user_activities
user_groups
photo_upload
video_upload
The list of privileges is not only meant for the photo upload.
The login and it's implementation works quite well, so that I get an 'access_token' and an 'expires_in' field in the answer.
If I don't have it already saved, I'm getting the user ID of the authenticated user represented by the access token. This is done by a simple request to:
https://graph.facebook.com/me?access_token={0}
{0} is the acquired access token
This also works quite well and I get a positive response with name, e-mail etc. and the user ID.
Next Task, get the list of albums the user associated with the acquired access token and the user ID. This is done by a FQL query:
SELECT aid,can_upload,created,name,description FROM album WHERE owner={0}
{0} is the user ID
The FQL query is executed by calling this URL:
https://graph.facebook.com/fql?q={0}&access_token={1}
{0} the query from above
{1} the access token
Again, this works quite fine - I get the requested fields back. The 'aid' values are used as album IDs later and are in the format 99999999_999999999 (numbers with an underscore somewhere in the middle). I only use albums that have the can_upload flag on "true".
Now, I hope I have all the information I need to publish the photos.
I create a POST request, multipart/form-data, to this URL:
https://graph.facebook.com/{0}/photos?access_token={1}
{0} is the 9999999_999999 album ID
{1} is the access token from the login
The request consists of two fields: 'source' contains the photo's binary data, 'message' the caption.
The request succeeds. No problem detectable for me.
But when I now visit the Facebook user page, the photos are not in the selected album, they are in an extra album named '"appname" Photos'. The caption is set correctly.
What must I change to bring the photos directly to the desired albums?
The aid is not the ID you should be using when you do the upload. This is not obvious from the Facebook docs - but you should use the object_id column as this represents an object on the Graph API.
So, change your FQL query to:
SELECT object_id,can_upload,created,name,description FROM album WHERE owner={0}
The object_id is just a number - not two numbers separated with an underscore. So make your post to:
https://graph.facebook.com/{0}/photos?access_token={1}
{0} is the 9999999 object ID
{1} is the access token from the login
Note that you only need user_photos permission to upload photos. But without publish_stream permission they do not appear in the user's album straight away - instead, when the user browses to the album they will see this:
Once they click approve they will appear in the album. If your application has publish_stream then they will go straight into the album and the user will not need to approve them.
The rest of your code should be correct.
The redirect URI, set to
'https://www.facebook.com/connect/login_success.html', as I'm working
on a desktop application
I'm not clear how you are getting USER'S access token in this case. To me it looks like you don't get it but instead you are using your APP'S token - that's why weird album name. Can you double check in Token Debugger that you indeed use user's token?
I have similar workflow for one of my windows forms app - but I do redirect user to localhost - that's where my WCF service is listening and acquiring user's access token from.
I need to get the living city of each person in a group. Including people that are not my friends.
In the browser seeing facebook profile of some unknown person, they show "lives in ...", if this is set as public information. They include the link to the city object with the city id in the link. That's all that I need.
But, using a facebook app that I created to use the facebook graph api, this information is not public. I can only get the user propriety 'location' from friends of my that I have permission to see it. I gave ALL the possible permissions to my app.
In the api explorer, when I use it as REST, they show few informations about someone not friend of mine.
https://developers.facebook.com/tools/explorer/
Also in the api explorer, when I use the FQL, it didn't works.
This query works, returning the JSON with the data:
SELECT uid, name FROM user WHERE username='...';
But this other query doesn't work:
SELECT uid, name, location FROM user WHERE username='...';
They return a json with a error code:
{
"error": {
"message": "(#602) location is not a member of the user table.",
"type": "OAuthException",
"code": 602
}
}
I asked for ALL the permissions options in the token. And I can get this info in the browser version of the facebook. But how can I get it with the API ?
The location field only exists in the Graph API table. Since you are using FQL, here are the location fields available to you:
current_address: the current address of the user,
current_location: the user's current location,
hometown_location: the user's hometown (and state).
Permissions:
user_location or friends_location permissions to view: current_location,
user_hometown or friends_hometown permissions to view: hometown_location.
Source: https://developers.facebook.com/docs/reference/fql/user/
When I access the list of my friends using the URL https://graph.facebook.com/me/friends?access_token=... I can see the list of my friends. I can do this programmatically as well.
Now, when I take the ID of any of my friends and replace it with "me" in the above URL, and paste the URL in the browser, I can see my friend's friends. I am unable to do this programmatically because it is giving me an HTTP 400 ERROR.
Does anyone know why this is possible by pasting the URL and not programmatically?
You can not get the "friends of friends" using the facebook api.
For example, try the simple /me/friends with the Graph API Explorer, it should work fine.
Then, take one of the ids there and try the same with FRIEND_ID/friends and you should get this:
{
"error": {
"message": "(#604) Can't lookup all friends of FRIEN_ID. Can only lookup for the logged in user or the logged in user's friends that are users of your app.",
"type": "OAuthException",
"code": 604
}
}
The error itself is very straight forward and explains exactly what the problem is.
As for why that translates into a 400 error code for you is unclear.
Edit
You can't see the "friends of friends" in the browser as well, the reason that it works for you (probably) is that the user(s) you check the friends for (USER_ID/friends) installed the app that the access token belongs to, from the way you got to that url I assume that the app is the "Test_console".
How to check? Copy the access token from the url (USER_ID/friends?access_token=xxxxx), go to the Facebook Debugger and paste the token in the text field and click "Debug", it will show you info regarding the application.
The user you checked it for probably has that app "installed", if you check it for other users you will get that error when you get to a user who does not have that app "installed".
I hope this clarifies it for you.
I got friends of friends(limited) who are using application. I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
We can get friends of friends those are app users.
$fb_id= user id whose friends of friends required.
Try this fql query.
$query="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT
uid2 FROM friend WHERE uid1 IN (SELECT uid FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1) )";
It needs following requirements:
Your friend needs to be using application.
Permission from application read_stream, publish_stream, publish_checkins.
In my application I'm trying out to list only the friends who are all single.
I tried different methods and it didn't return proper values...
I tried the graph API but could list only all the friends irrespective of their relationship status.
i tried $facebook->api("/$user/friends?relationship_status='single'");
Also i tried to use FQL and fetch things up but the relationship status always return up as 'null' for even the user who have approved the applications and gave permission to access their relationship_status..
the fql query i tried is
SELECT
uid,name, relationship_status, current_location
FROM user
WHERE
uid IN (SELECT uid2 FROM friend WHERE uid1 = 2343434434234)
How can i get this done?
The problem is that you're only asking for that user's relationship status. You need to also ask for the friends_relationships permission. Once you do that, your query will work fine.
I've been looking at this at every possible angle and I can't make my mind around it, maybe you guys can help. I run this query to get my friend's hometown and location:
SELECT uid, name, timezone, hometown_location, current_location
FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() )
And hometown_location and current_location are always NULL, even when they shouldn't be. Using something like /me/friends?fields=hometown,location,... has the same result.
Also, querying for my own hometown_location and current_location DOES WORK. Which makes me think I don't have the permissions to access my friends' hometown & location.. but shouldn't then an error be raised, if this was the case?
Still, my app has the same permissions: user_about_me, friends_about_me, user_hometown, friends_hometown, user_location & friends_location, so I don't think this is the issue.
If I go to http://developers.facebook.com/docs/reference/api/ and click on the https://graph.facebook.com/me/friends?access_token=... link, and I append &fields=name,hometown, it works, so I know it can be done.
Any idea what could I be doing wrong?
Thanks a lot!
Manuel
For friends_hometown you need friends_hometown permission.
For current_location you need friends_location permission.
Once you ensure you have those permissions you should be able to get the data by running that query or through the Graph API - https://graph.facebook.com/FRIEND_ID?fields=hometown,location with an access_token having those permissions.
Are you using Simon Cross' interface?
https://www.simoncross.com/fb/graph/
It can help you understand what is the problem. Try to regenerate your access_token you might still use an old token which didn't have extended permissions for friend_hometown.
The API doesn't throw any kind of error in case you (or the token used) don't have permission to access the data