facebook fql for retrieving photos returns empty list [] - facebook-fql

select object_id, aid, src_small from photo where owner='{0}' ; {0}-the id of the user.
This query returns 0 records. Do you know why?

There may be an issue with permissions. You may need to grant user_photos permission.
See here - http://developers.facebook.com/docs/authentication/permissions

Related

FQL Error: requires extended permission: read_stream

Today I started get some strange FQL Error.
FQL query: *SELECT target_id FROM connection WHERE source_id = user_id1 AND target_id = user_id2*
*SELECT uid FROM user WHERE has_added_app=1 and uid IN (SELECT uid2 FROM friend WHERE uid1 = "user_id")*
FQL Response (Error): Error: Requires extended permission: read_stream
What is it???
Help.
According to their Change Log, on 2011-09-18, Facebook pushed this update:
FQL connection table now requires read_stream permission. (rE435878)
I had the same problem. I was only using the connection table to get a list of friends, so I was able to change to the friend table to pull the info I needed.
Stuff like this is what makes Facebook Platform a hostile development environment.
Looks like facebook has changed some of the required permissions for some actions this night. The same happened to me. You need to ask for read_stream permissions. For more information refer here
P.S: You might need to remove the application from your profile and add it again with the new permissions

How to get facebooks friends who are all single using either PHP sdk or FQL?

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.

Facebook API: friends' hometown_location and current_location always empty using FQL

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

I'm getting "The indexed user_id queried on must be the logged in user" when i query my friends likes

here is my query:
FB.api(
{
method: 'fql.multiquery',
queries: {
'friends':'SELECT uid1 FROM friend WHERE uid2= me()',
'likes':'SELECT object_id FROM like WHERE user_id in (SELECT uid1 FROM #friends)'
}
});
Some FQL queries require that the queried user be logged in. In order to run theis queries without the user being logged in, your app must have the offline_access permission.
indexed fields cannot be queried except actual user
for query your friends likes look at How to get friends likes via Facebook API

How can I count the total friends of a Facebook user by uid?

How can I count the total friends of a Facebook user by uid?
There is a friend_count field against the user table that you can query.
SELECT friend_count FROM user WHERE uid = me()
Just replace me() with the UID of the user that you want to query.
#Scott
This very much works, I didn't expect it to :)
https://graph.facebook.com/fql?q=SELECT friend_count FROM user WHERE uid = 273103345
I tried with a random user id who is not a friend in Graph API. However for few random uids it returned null, I am guessing they were pages.
FQL is now deprecated as of October 2014. Quoting Facebook's FAQ :
As of Tuesday 22nd July 2014, we now return a total_count field within
a summary property in the response to /v2.2/me/friends.
The user/friends endpoint does require the user_friends permission to return an actual list of friends who use your app, however the friend count field will still be returned without this the user_friends permission granted. Sample response:
{
"data": [
],
"summary": {
"total_count": 811
}
}
Full FAQ: https://developers.facebook.com/docs/apps/faq#total_friend_count
COUNT is not supported by FQL:
SELECT uid2
FROM friend
WHERE uid1 = USERID
Since COUNT is not supported you need to get all of the records and then count them in whatever application that is making the SQL call.
If you want to get more information, like names, along with count you can use an inner select to get the friend's extended info:
SELECT name
FROM user
WHERE uid IN (SELECT uid2
FROM friend
WHERE uid1 = USERID)
Here is a related SO question:
FQL result count
References for Friend table:
Query this table to determine whether
two users are linked together as
friends.
Heres my solution... works great!
$myfriends = $facebook->api('/XXXXXXX152466/friends');
$friendcount = COUNT($myfriends['data']) + 1;
Replace XXXXXXX152466 with the facebook profile id#
Using Facebook PHP SDK along with Graph API!
Starting with Facebook API 2.0 you can't get the full list of Facebook friends, only a partial list of friends that also authorized your app.
You can still get the total number of friends though, the Graph API user/friends has a field summary containing the count as total_count
So you can get it using:
FB.api("/me/friends", function (response) {
if (response && !response.error) {
console.log(response.summary.total_count);
}
});
There are lot of way to count the no of friends using Facebook Graph API with Php SDK, out of one i am telling..
$fbuser=$fb->api('/me/friends');
$access_token = $fb->getAccessToken();
$friend_count=0;
foreach($fbuser['data'] as $friends)
{
$friends_count++;
}
For complete tutorial visit this article Getting FB Friends Count