FQL query doesn't return the correct results - facebook-fql

I'm running the following fql query in the graph explorer:
select album_object_id, object_id, aid, pid from photo where object_id=576544082370719
and i get the correct results i want:
{
"data": [
{
"album_object_id": 520085011349960,
"object_id": 576544082370719,
"aid": "396713620353767_120902",
"pid": "396713620353767_2121634"
}
]
}
however, when adding album_object_id to the statement, nothing is returned:
select album_object_id, object_id, aid, pid from photo where object_id=576544082370719 and album_object_id=520085011349960
{
"data": [
]
}
anyone has any idea?
I tried to report it but they said they can't reproduce
https://developers.facebook.com/bugs/448684285215430
here is another example which doesnt work but it supposed to, what is going on?
select object_id, modified from photo where object_id=507652032628572
this gives the correct result, however:
select object_id, modified from photo where album_object_id=468672926526483 and modified>1365522434
no results on this one.

found out that when adding order by modified desc to the statement, results are fine, thats some kind of work around but well, at least works.

Related

How to get photo Like Info from graph explorer?

Can any body tell me how to get the photo Like Info from graph explorer?I tried this fql query
select like_info from photo where object_id=PHOTO ID
Using this query This photo Id-10152460216420695 gives me result
{
"data": [
{
"like_info": {
"can_like": true,
"like_count": 2118,
"user_likes": false
}
}
]
}
But this photo Id-551468638224054 gives me result
{
"data": [
]
}
This two photo are the public and both have more than 1 like.So why the last one can not give me the right result?Waiting for your help...
You can use :
select like_info from photo where object_id="PHOTO ID"
If it fails than it means The photo is invisible for graph api.
One of those photos may not be available via the API due to privacy settings. Even though a photo is public on Facebook itself, there may be other reasons why the piece of content isn't emitted via the API.

How do I know if a Facebook Status/Photo/Link is Private?

When I'm getting a status/link/photo from facebook API, how do I know if it has been shared with the public or if it's a private post?
Also - is there a way to query only public posts?
I'm currently using the /<username>/status /<username>/links /<username>/photos endpoints.
With the graph api
From the 3 endpoints you are using, only one gives you access to the privacy settings the /<username>/links. It returns a privacy object, something like this:
{
"id": "USER_FB_ID",
"links": {
"data": [
{
"id": "ID_OF_THE_POST",
"from": {
"name": "Fábio Antunes",
"id": "USER_FB_ID"
},
"message": "Check this awesome link",
"privacy": {
"description": "Friends; Except: Restricted",
"value": "ALL_FRIENDS",
"allow": "",
"deny": "",
"networks": "",
"friends": ""
},
(etc....)
With FQL
To solve your problem you could use FQL this way you can get the 3 endpoints that have public access.
For the links you can use this query:
Select link_id,owner_comment, title, url, privacy FROM link WHERE owner = me() AND privacy.value='EVERYONE'
note: check the link table to see if there are any fields that you may want to add to this query
Since the links table from the 3 endpoints is the only with privacy settings structure to get the user photos and statuses that are public you will have to use the privacy table.
To get all the users public photos I made 2 joins, first I'm getting the user photos, then I want the privacy settings of the photos that are available to everyone and then I select the photos that have the privacy settings public:
SELECT caption,src_big FROM photo WHERE object_id IN (SELECT id FROM privacy WHERE value='EVERYONE' AND object_id IN (SELECT object_id FROM photo WHERE owner=me()))
note: check the photo table to see if there are any fields that you may want to add to this query
To get the public statuses it's the same process for the photos, two joins:
SELECT status_id , message, place_id FROM status WHERE status_id IN (SELECT id FROM privacy WHERE value='EVERYONE' AND object_id IN (SELECT status_id FROM status WHERE uid=me()))
note: check the status table to see if there are any fields that you may want to add to this query

Getting images from facebook group album

I'm having a problem with the Graph API / FQL and I have searched however no solution has come up.
I'm unable to retrieve photos from a group album.
I can retrieve a lot of information regarding that group album which indicates that a group album is just a regular album:
SELECT description, owner, photo_count, type, like_info,
cover_pid, comment_info FROM album WHERE object_id = '1382173765340875'
{
"data": [
{
"description": "10 Desafio Outros!!!",
"owner": 1455136613,
"photo_count": 8,
"type": "normal",
"like_info": {
"can_like": true,
"like_count": 1,
"user_likes": true
},
"cover_pid": "6249764165120950711",
"comment_info": {
"can_comment": true,
"comment_count": 0,
"comment_order": "chronological"
}
}
]
}
Calling "/1382086785349573" gives me the group information.
Calling "/1382086785349573/albums" gives me a list of all the albums in the group including ID, album name and even correct count.
but "albumid/photos" where album ID was retrieved from previous call returns an empty array
Also "/groupid/photos" returns an empty data[] array.
Can anyone tell me why this happens? I already removed my app from sandbox mode but still showing the same problem.
I don't understand why it can retrieve album information including items count and etc but not the photos in it.
Thanks in advance for any help.

Is FQL giving wrong typage?

I am starting with FQL, and I am having some issues with columns' type being not as expected.
For example, docs of table friend says that uid2 is an int, but I receive strings when I lookup this table:
SELECT uid2 FROM friend WHERE uid1 = me()
that gives me:
{
"data": [
{
"uid2": "100004469923697"
}
]
}
and with photo table too, when I expect a string at owner:
SELECT owner FROM photo WHERE owner=me()
...I receive an int:
{
"data": [
{
"owner": 100004536330032
}
]
}
Is that right?
Edit: Not parsed data, raw, as received from source and explorer
It appears that json is loosely typed, and depending on the parser used to generate the json objects numbers can be arbitrarily typed as strings or integers.
According to this Wikipedia entry, "One disadvantage is that the number 25 is reflected as a number, but may have been a string as base type in a database." No reference is given, and a quick Google didn't shed any light on this.
You'll just have to be aware that when getting json data from Facebook, the type received may not always be the type expected.

FQL query of photos for Facebook users with large numbers of photos

I need to get photos of an FB user sorted by likes.
I ran this FQL query via Facebook JavaScript SDK to get them:
SELECT object_id, src_big, src_big_width, src_big_height, link, like_info, caption, created
FROM photo
WHERE owner = MANY_PICS_USER_ID ORDER BY like_info DESC LIMIT 10
The query fails for users with more than 3000 photos. Turns out there are a lot of those users. Related Facebook bug is here http://developers.facebook.com/bugs/438568326189781
As a note: removing "ORDER BY like_info" makes query work, but there is no easy way for me to get those pictures, sorted by likes
To reproduce:
Pick a FB friend with at least 3000 photos, get their user Id, and run the above query (replacing MANY_PICS_USER_ID) in API GRAPH EXPLORER.
What is the best workaround? Or, can you suggest the easiest light-weight Open Graph solution?
To sort photos by likes you need the following:
Run the query which gives first 100 results (replace me with user id):
http://graph.facebook.com/me/photos?fields=id,source,likes&limit=100
Which return the following data structure:
"data": [
{
"id": "1234567890",
"source": "http://photo.url.in.facebook.cdn.com/",
"created_time": "2012-09-13T22:52:34+0000",
"likes": {
"data": [
{
"id": "1234567890",
"name": "Full Name"
},
.....
"paging": {
"next": "https://graph.facebook.com/1234567890/likes?limit=25&offset=25"
}
}
},
{
"id": "312323232323",
"source": "PICTURE_URL",
"created_time": "2012-09-12T20:54:27+0000",
"likes": {
"data": [..]
}
},
....
"paging": {
"previous": "http://PREVIOUS_URL?fields=id,source,name,height,width,link,likes&limit=100&since=123456",
"next": "http://NEXT_URL?fields=id,source,name,height,width,link,likes&limit=100&until=234567"
}
If total number of pictures is more than 100, run all next queries,
from the "next" link until the num of pics will be less then 100.
For every picture you need to count total number of likes. If the
number of likes is more than 25, run extra query from
likes.paging.next until number of likes will be < 25 and get the
total quantity.
Sort all those pics by number of likes.
So for the user with 3000 pics it will be in total 30 calls + extra calls for each picture with more than 25 likes.