I'm trying to get insights from facebook for some pages I have admin rights to. I'm able to get the correct data with the graph API but when I try with FQL I get an empty JSON object. Any idea what the problem may be?
I think the query is correct because I do not get any 400/500 errors. I also think the permissions are correct because I'm using the same framwork with the graph API solution and it works fine. Maybe you need additional permissions to use FQL? I have manage_pages and read_insights.
I'm implementing with basic text replacement on the template URIs from facebook's documentation.
EDIT: I think the problem may be that I don't actually have the read_insights permission. I do have the manage_pages permission. Perhaps this explains why I can access insights through Graph API but not FQL?
Graph API query:
string insight_str = "https://graph.facebook.com/APP_ID/insights/FIELD/FREQ?access_token=ACCESS_TOKEN";
string url = insight_str.Replace("FIELD", "page_impressions").Replace("FREQ","day").Replace("APP_ID", accounts[i].id).Replace("ACCESS_TOKEN", accounts[i].access_token);
https://graph.facebook.com/xxxxxxxx/insights/page_impressions/day?access_token=xxxxxxxx
Graph API parsed JSON result:
page_impressions
2011-12-28 412
2011-12-29 971
2011-12-30 373
FQL query:
string query_str = "https://graph.facebook.com/fql?q=QUERY&access_token=ACCESS_TOKEN";
string query = "SELECT+metric,value+FROM+insights+WHERE+object_id=APP_ID+AND+metric='FIELD'+AND+end_time=1322722800+AND+period=86400";
string url = query_str.Replace("QUERY",query).Replace("FIELD","page_impressions").Replace("APP_ID",accounts[i].id).Replace("ACCESS_TOKEN",accounts[i].access_token);
https://graph.facebook.com/fql?q=SELECT+metric,value+FROM+insights+WHERE+object_id=xxxxxxxx+AND+metric='page_impressions'+AND+end_time=1322722800+AND+period=86400&access_token=xxxxxxxx
FQL JSON result:
{"data":[]}
I have the same problem with Facebook C# SDK version 5.4.1 and 5.3.2 (see my post Error with FQL query with library 5.4.1)
I always receive an empty response like you.
You must have the read_insights permission.
I think the end time in your example is slightly off. It needs to fall exactly at midnight PST. I obtained a value once I moved the time forward an hour, to 1322726400.
Related
We have used the v2.0 graph API & FQL(FaceBook Query Language) for getting the FaceBook details in our project. But recently the result is empty.
I have checked the developer.facebook.com and i found one solution that is Login Review process. We need to get the FB details means we need to get the pre approval from FB.(user_photos, user_videos) It'll work perfectly or not ?
https://developers.facebook.com/blog/post/2015/04/28/april-30-migration/
Sample Code :
args = "SELECT uid,name FROM user WHERE uid = me()"
file = urllib2.urlopen("https://api.facebook.com/method/fql.query?" + urllib.urlencode(args), timeout=3)
Please give some suggestion to fix this problem.
https://developers.facebook.com/docs/apps/api-v1-deprecation
Advance Thanks :)
Have a look at
https://developers.facebook.com/docs/apps/changelog#v2_1_deprecations
The FQL and REST APIs are no longer available in v2.1: Previously announced with v2.0, apps must migrate to versioned Graph API calls starting with v2.1.
You're querying the REST API which is deprecated, as cited. Use https://graph.facebook.com/fql instead.
Getting notification from FB, they will remove FQL inthe later release after 2.0 which is expect to be on 2016.
Currently my Apps are using FQL to get the like_count and share_count. I hope someone can share with me how to achieve this in GraphAPI2.0 because in GraphAPI, I only able to retrieve the total count.
https://api.facebook.com/method/fql.query?query=SELECT%20url,%20share_count,%20like_count,%20comment_count,%20total_count,%20click_count%20FROM%20link_stat%20where%20url=%27http://www.google.com%27
<fql_query_response list="true"><link_stat>
<url>http://www.google.com</url>
<share_count>5860640</share_count>
<like_count>1446662</like_count>
<comment_count>1775201</comment_count>
<total_count>9082503</total_count>
<click_count>265614</click_count>
</link_stat></fql_query_response>
http://graph.facebook.com/?id=http://www.google.com
{
"id": "http://www.google.com",
"shares": 9082503
}
The more up to date way of using your FQL would be
https://graph.facebook.com/fql?q=SELECT%20url,%20share_count,%20like_count,%20comment_count,%20total_count,%20click_count%20FROM%20link_stat%20where%20url=%27http://www.google.com%27
If you'd like to use the old (deprecated, but still working) api.facebook.com endpoint, try
https://api.facebook.com/method/links.getStats?urls=http://www.google.com&format=json
This doesn't employ FQL at all, but you can't be sure how long this works. It's not even in their docs anymore. FQL will be around 2 years from the moment Facebook announces the successor of the Graph API v2.0, so I would recommend go go along with the first suggestion.
Graph API v2.0 doesn't have an endpoint IMHO to generate URL sharing stats other than the FQL method.
Has anyone seen a full example of how to pull facebook reviews using the graph api.
According to the docs:
A page access token is required to retrieve this data.
I have code that asks a user to login already and gets an auth token which I can use to post a message to their facebook feed. Is there an additional step I need to do to be able to read their reviews/ratings?
Here is an example of the code to post to their feed/page.
response = Curl.post("https://graph.facebook.com/#{page_id}/feed", {
:message => message,
:access_token => auth_token
})
Thanks
If you're referring to Page Ratings (different from App Reviews!), then the endpoint is
GET /{page_id}/ratings
as described here: https://developers.facebook.com/docs/graph-api/reference/page/ratings You'll need a Page Access Token for this.
Where I get a little bit confused is that you mention that you want to
read their reviews/ratings
In that case it's something else, because afaik it's currently not possible to query the User's Page ratings via Graph API or FQL. It's was only possible to query App Reviews via FQL (see https://developers.facebook.com/docs/reference/fql/review/) (Update: FQL is no longer available since 2016)
You need to set permission in the app to access the {GET /{page_id}/ratings} API. The permission is common for
/page/comments,
/page/posts,
/page/ratings,
/page/tagged,
and the permission name is "pages_read_user_content"
https://developers.facebook.com/docs/permissions/reference/pages_read_user_content
I am searching the public feed and once I get the objects I want to get more information on them. I login with an auth token and when I try to get more information through both the graph API and FQL I get the following results.
Graph API - I run the following request "https://graph.facebook.com/{pid or object_id}"
Results - I get the error "Unsupported get request."
FQL query - I run something like "Select {fields} from photo where pid = '{pid}'"
Document - "To read the photo table you need any valid access_token if it is public and owned by the Page."
Results - I get an empty data array.
This used to work and I am not sure if I am doing something wrong or this functionality has changed?
Thank you for any insight you might have,
Stefanie
Facebook says this is "By Design" via developers.facebook.com/bugs/285682524881107
I tried the below query
SELECT metric, value FROM insights WHERE object_id=3232322 AND
metric='application_active_users' AND end_time=end_time_date('2011-12-12') AND
period=period('day')
I've got read_insights permissions,object_id,i'm passing the page id.
This insights,i create as an facebook app ,to this i'm passing the app access token.
I get an empty array as output.Am,i missing some thing?
I don't think it is an authentication issue because it would return an error (authentication error)
This might be a known issue with end_time; check bug already reported to facebook. I have posted a work around there too that works.
http://developers.facebook.com/bugs/232510993491615?browse=search_4f08c675cce9d2265724293