Basicly what I am trying to do is to get the post impressions from a page that I am and admin for and own and from the Graph API explorer have permission to view the insights. However when i run this:
SELECT metric, value FROM insights WHERE object_id=10151215628833061 AND metric='post_impressions' AND end_time=end_time_date('2012-12-7') AND period=0
I have set the object id to equal the to the posts id and the period to 0 which is lifetime but have no success.
All i get back is this:
{
"data": [
]
}
Can not figure out whats wrong with this, does anyone know what I am doing wrong?
Your post was created yesterday, but you're asking for metrics as of a month ago. The post didn't exist then, so there is nothing to return.
Change your query to this:
SELECT metric, value FROM insights WHERE object_id= '82346848060_10151215911933061' AND
metric='post_impressions' AND period=0
You want to quote the object ID just in case a post you're querying contains an underscore.
Related
I use
<fb:comments-count href=http://e-drpciv.ro/intrebare/963/></fb:comments-count>
I also try with quotes
<fb:comments-count href="http://e-drpciv.ro/intrebare/963/"></fb:comments-count>
and the return is always zero:
/**/ FB.__globalCallbacks.fdd5cbfe8aa94c({"data":[{"name":"index_link_stat_url","fql_result_set":[{"url":"http:\/\/e-drpciv.ro\/intrebare\/963\/","commentsbox_count":0}]}]});
Some other links report less comments than real.
Eg. http://e-drpciv.ro/intrebare/35 report only 3 comments
I need to update something in my code? Or is just a facebook issue and I need to wait?
This problem persist for two days.
If someone shares someone else story it wouldn't show you the comments of that previous share in your /home, but when you query the fql to get comment_count of that object "SELECT comment_info FROM photo WHERE object_id = 1234567890" it will count you all comments from all shares, this is why when you query the /home with FB API you will find posts without comments but with the SELECT ... it will return you positive number of comment's count. i belive that there is some join to make or to can get only the current user.
I'm running a few fql queries to try and pull insights data into my own tables where i could display them. The problem is that nothing is returned- here is a sample query
SELECT metric, value FROM insights WHERE object_id='000' AND metric='application_stream_stories' AND end_time = end_time_date('2012-04-02') AND period=period('day')
This returns a pair of empty square brackets. It doesn't even return the column names with the zero value.
If i do another query- this time changing the metric- it returns a zero value json array
SELECT metric, value FROM insights WHERE object_id='000' AND metric='application_active_users' AND end_time = end_time_date('2012-04-02') AND period=period('month')
and the result-
[{"metric":"application_active_users","value":0}]
i have tried these queries use php and the fql console on facebook- does this table work (http://developers.facebook.com/docs/reference/fql/insights/#application_content) i have cycled through most of the metrics finding nothing working.
Yes it works, ensure you have the read_insights permission. If you don't you will get an empty array. application_active_users does not need read_insights only a valid access token.
Any valid access_token for the publicly available application_active_users metric
https://developers.facebook.com/docs/reference/fql/insights/
i am usig Facebook fql.multiquery to fetch data with command line. like this
$queries = '{
**"query1" : "SELECT metric, value
FROM insights WHERE object_id=148945955209922
AND metric="application_active_users"
AND end_time=end_time_date("2011-12-10")
AND period=period("month")",
"query2" : "SELECT metric, value
FROM insights WHERE object_id=148945955209922
AND metric="application_active_users_city"
AND end_time=end_time_date("2011-12-10")
AND period=period("month")"
}';
But while running this code it is showing empty Array.
can anybody help me?
I would first start troubleshooting your access token. Ensure your access token has the appropriate permissions. Secondly, ensure the queries run independently of each other by running each one separately thru the normal FQL. You can play around with the FQL structure using the Graph API Explorer tool https://developers.facebook.com/tools/explorer
I'm doing a query to get the total likes for a domain and I am using the following:
https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=xxxxxxxxx AND metric='domain_widget_likes' AND end_time=end_time_date('2011-08-27') AND period=period('lifetime')&access_token=xxxxxxxxx
I already claimed my domain, have the object id for my domain and installed an app to get access to insights and send the token.
But return nothing, if I try with period('day') the query works fine but I need all likes not only daily.
Anyone knows if it is a new rule on the insights data or is a bug?
Thanks a lot.
Are you able to use a wildcard % in the query like so (period LIKE period('%')):
https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=xxxxxxxxx AND metric='domain_widget_likes' AND end_time=end_time_date('2011-08-27') AND period LIKE period('%')&access_token=xxxxxxxxx
String Comparison Functions Reference has more info on query wildcards, etc.
I'm trying to get demographics for fans of a page on Facebook - mostly country and city, but age and gender as secondary.
The primary way to do it is using FQL and doing a query in the insights table. Like so:
FB.api({
method: 'fql.query',
query: "SELECT metric, value FROM insights WHERE object_id='288162265211' AND metric='page_fans_city' AND end_time=end_time_date('2011-04-16') AND period=period('lifetime')"
}, callback);
The problem with this, however, is that the table returns a maximum of 19 records only, both for the country and the city stats. The response for a page I'm testing is as such:
[
{
"metric": "page_fans_city",
"value": {
"dallas": "12345",
"atlanta": "12340",
(...)
"miami": "12300"
}
}
]
So I'd like to know if there's any alternative to that -- to get demographics of the current fans of a page (no snapshot necessary).
Things I've tried:
Using LIMIT and OFFSET on the query do nothing (other than, sometimes, give me an empty list).
One alternative that has been discussed in the past is to use the "/members" method from the Graph API (more here) to get a list of all users, and then parse through that list. That simply doesn't work - a method exists, and it may have worked in the past, but it's not valid anymore (disabled?).
Request:
https://graph.facebook.com/platform/members?access_token=...
Response:
{"error":
{
"type":"OAuthException",
"message":"(#604) Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http:\/\/developers.facebook.com\/docs\/reference\/fql "
}}
Other solution was to do a query to the page_fan table and filtering by page_id. This doesn't work, either; it may have worked in the past, but now it says that the page_id column is not indexable therefore it cannot be used (same error as above, which leads me to believe /members uses the same internal API that has been disabled). Page_fan query is only useful to check if individual users are fans of a page.
There's also the like table, but that's only useful for Facebook items (like posts, photos, links, etc), and not Facebook Pages.
Going to the insights website about the Page, you can see the data in some nice graphs and tables, and download an Excel/CSV spreadsheet with the historic demographics data... however, it also limits the data to 19 entries (sometimes 20 with a few holes in there as cities trade top positions though).
Any other hint on how to get that data? I'd either like the insights query with more results, or at least a way to get all the page fans so I could do the location query myself later (even if the page I want to get it from has almost 5 million fans... gulp).
The data pipeline for this metric is currently limited to 20 items. This is a popular feature request and something Facebook hopes to improve soon.