insight using fql for facebook application - facebook

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

Related

Facebook API For Pulling Reviews

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

A specific Fan Page ID is not returning FB Graph data

We are working with High Times Magazine (http://www.facebook.com/HIGHTIMESMag, profile id: 23237898444). I've tried checking via FB's graph to see if the proper data returns, and it doesn't for some reason. You can check here as well:
https://graph.facebook.com/23237898444 and http://graph.facebook.com/HIGHTIMESMag
Does anyone else have this issue? How can I get the id to work, or is this a Facebook bug?
Accessing it with a valid access token (i.e. https://graph.facebook.com/23237898444?access_token=...) works for me. This usually means the page is age- or locale-gated.

using facebook graph API vs FQL insights

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.

Facebook Graph API - get friends info

I'm trying to figure out how to get users friends information using either Graph API or FQL
Just for testing I would like to get my friends education_histroy.
To do that I created a test app, requested extended permissions using
scope=offline_access,manage_friendlists,friends_work_history,
friends_education_history,friends_about_me
and got access token to play with the API.
It works great when I query for current user using /me. But it returns nothing for my friends.
I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:
https://graph.facebook.com/FRIEND_ID&access_token=TOKEN
But all I see is basic info about that user (friend).
Then I tried to request that field specifically:
https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN
With no luck again. Returns just friend's id..
I tried to access that information with FQL:
https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN
Returns work_history = TRUE instead of array. And that friend definitely has work history specified.
Can someone help me to understand how to get friends info using my app and extended permissions?
Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.
Following is a list of extended permissions related to friends different kind of information
friends_about_me
friends_activities
friends_birthday
friends_checkins
friends_education_history
friends_events
friends_games_activity
friends_groups
friends_hometown
friends_interests
friends_likes
friends_location
friends_notes
friends_online_presence
friends_photo_video_tags
friends_photos
friends_relationship_details
friends_relationships
friends_religion_politics
friends_status
friends_subscriptions
friends_videos
friends_website
friends_work_history
Hope it helps :)
I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:
https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE
This will return you all the friends' info in one long JSON response.
It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.
The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.
http://developers.facebook.com/docs/reference/api/user/
you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission
in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.
From this answer to another question: a call to 'me/friends?fields=work' worked for me!
I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.
P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.
You can use this code you will get name, profile picture, ID of your friends.
FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});
Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.

Facebook API checkins not working?

Wondering if anybody has had any problems using the facebook graph api to get checkins.
https://graph.facebook.com/me/checkins?access_token=2227470867|2.SOgfV3_Dc6iX_IzJctERXA__.3600.1292436000-666790342|UPcbXaafo7G5rd2I_7d9_LpeZFo
returns
{
"data": [
]
}
and any other ids insted of "me" return the same.
Anyone have any ideas?
Turns out you can't access the fb places api outside the US
Allright fellows,
after some tries I can shed a light to this topic, here comes the description of the solution.
You can make such requests only by authorized apps.
I implemented the flow on Android and works like a charm,
here is an example call grabbed from logs:
https://graph.facebook.com/me/checkins?format=json&sdk=android&access_token=<access_token>
important note: access token MUST have been retrieved by your application, which has permissions for
"user_checkins", "friends_checkins"
getting access token is straight forward flow, explained well in all SDKs (p.s. I'm using Facebook-AndroidSDK)