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.
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.
Facebook is planning to drop support for FQL after V2.0 https://developers.facebook.com/docs/apps/changelog/#v2_0_fql
The below task could be done easily with FQL
SELECT like_info.like_count, comment_info.comment_count, share_count
FROM stream
WHERE post_id = "POST_ID_HERE"
I am unable to find a replacement to the above method in graph api. I know we can get likes and comments count like
POST_ID/likes?summary=true AND
POST_ID/comments?summary=true
but I am unable to find a similar endpoint for shares.
NOTE: I am not looking for solutions that take URL input and query graph api for that URL shares, rather I am looking at finding solution to get shares count by POST_ID
PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)
I have looked at.
Facebook API: best way to get like, share, comment count for a page/group post?
How to get Likes Count when searching Facebook Graph API with search=xxx
Facebook post comment count from Graph API
http://www.quora.com/Facebook-Graph-API/Facebook-Graph-API-How-to-get-the-number-of-likes-on-a-status
The result should be something like this:
{
"data": [{
"like_info": {
"like_count": 3506
},
"comment_info": {
"comment_count": 263
},
"share_count": 278
}]
}
Any help would be highly appreciated.
Cheers!
UPDATE: It was an access token issue as the token I was using did not have "read_stream" permission.
The field shares does not need the .summary(true) at the end. It will bring always the total. But the likes and comments does need .summary(true)
Example:
[POST_ID]?fields=shares,likes.summary(true),comments.summary(true)
Improved version works with Graph Api v2.11 (add limit(0) to removes lists of likes and comments and get only summary data):
[POST_ID]?fields=shares,likes.summary(true).limit(0),comments.summary(true).limit(0)
This will bring the total count of shares, comments and likes.
You may have a access_token with an read_stream permission to get the shares count.
Get likes, comments and shares and all 3 combined.
Check my ans : https://stackoverflow.com/a/36997725/2439715
Improved version ( add limit(0) to removes list of likes and get only summary ):
114916098537132_1265715836790480?fields=shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
Get comments, shares, and likes count from post:
[POST_ID]/?fields=id,shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
I've included limit(0) to prevent the API from spitting out the actual comments and likes. I believe the default limit is 25.
Please note you can also add these fields to /feed to get this data for all the posts on the page.
[PAGE_ID]/feed?fields=id,shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
Final note: If shares data is missing on the return, it is because the post has no shares. Instead of returning "shares": {"count": 0}, the shares section will be removed entirely.
"https://graph.facebook.com/v2.2/PAGEid_POSTid/?
fields=shares&access_token=YOUR_ACCESS_TOKEN";
I am using above mentioned endpoint.
Replace $pageID and $videoID (post id) with your variables.
"https://graph.facebook.com/v2.2/" . $pageID."_".$video->id . "/?fields=shares&access_token=YOUR_ACCESS_TOKEN";
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
Edit: Seems like Facebook finally fixed this bug!
Could you help me understand why this is happening:
This is a public event with a picture:
https://www.facebook.com/events/282054218538223
But when I try to access http://graph.facebook.com/282054218538223/picture, all I get is a default picture.
Here is another public event: http://www.facebook.com/events/266496120103339
But this time, accessing http://graph.facebook.com/266496120103339/picture returns the event photo.
What's the difference between the 2 events?
This answer doesn't explain why the request doesn't work using Graph API but might help someone who needs to to retrieve event profile images.
With FQL you can retrieve the event profile image like this:
SELECT pic, pic_small, pic_big FROM event WHERE eid=282054218538223
using the event id from Robin's first example. This call returns urls to the event profile image in 3 different sizes. It works for both examples in Robin's question, just change the event id.
Try it in Graph Explorer with Robin's example:
https://graph.facebook.com/fql?q=SELECT pic,pic_big,pic_small FROM event WHERE eid=282054218538223
and MoXplod's example:
https://graph.facebook.com/fql?q=SELECT pic,pic_big,pic_small FROM event WHERE eid=271148229633674
Make sure you have access token if needed as outlined in the FQL event table.
having the same problem. it appears to indeed be a bug with the Facebook Graph API.
I currently count at least three separate open bug-reports on the Facebook Developers Bugs page that describe and reproduce the problem (you may need to be logged into FB to access the information) :
Cannot retreive picture of newly created events via Graph API
Some event covers not available via Graph API
Event picture is not accessible via API
fwiw, it might be a good idea to subscribe to all three (duplicate) bug-reports.
I was fighting with this problem this evening. The docs are saying to use picture but what I found exploring fields is this one:
{event-id}/?fields=cover
which finally returns:
{
"cover": {
"offset_x": 99,
"offset_y": 50,
"source": "{url}",
"id": "{id}"
},
"id": "{id}"
}
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.