I'm trying to get some statistical data from my page using FQL like so:
SELECT metric, value FROM insights WHERE object_id=278942378807967 AND metric='page_fan_adds' AND end_time=1327903200 AND period = 2592000
However all that is returned is:
{
"data": [
]
}
I also tried different dates and periods, most of which I'm pretty sure there should be data presented...
You're probably missing a valid access token on your query to get the stats.
period can only be 86400 or period("day")
Related
I am looking for something like FOUND_ROWS() in mysql select query in algolia results as I need to keep a track of how many total results to expect. Is there someway to get this in Algolia?
The proper way to obtain the number of results is to access the nbHits value which is available in the JSON response of every search call.
These days I have had the pleasure to play a little bit with the facebook api, but there are things that I can not understand. I'm searching for all the pages that are close to some point, using this FQuery (Query1):
SELECT page_id,name FROM place WHERE distance(latitude, longitude, "45.698944", "8.462454") < 50000
This query returns a list of pages, but not all. For example, this query (Query2):
SELECT page_id,name,distance(latitude, longitude, "45.698944", "8.462454")
FROM place
WHERE distance(latitude, longitude, "45.698944", "8.462454") < 50000 and page_id=656799421018484
returns:
{
"data": [
{
"page_id": "656799421018484",
"name": "Formatamente",
"distance_meters": 16006.10107316
}
]
}
My problem is that Query1 not return "Formatamente" (result of Query2) though the distance ( 16006.10107316 ) is less than 50000.
I also tried facebook graph:
https://graph.facebook.com/search?distance=50000¢er=45.698944,8.462454&type=place&fields=id,name&access_token=TOKEN
but it still not returning "Formatamente".
Is there some trick to find all places around me? I will use this page_id to search all events created by this pages, or is there an easier way to find events nearest gps point?
Thanks in advance
Have a look at my answers
Facebook Graph API Get All Events For Latitude and Longitude
Facebook FQL find all events that take place at a certain venue
You're not getting the specific Page you mentioned because your're using the biggest radius possible (50000m), which yields in probably tens of thousands results (which FB is not returning completely). You can use LIMIT start, number in your query, but still FB won't return a high five-digit amount of results at once.
I am trying to use limit along with since and until in Graph Api call. In between a certain time interval, I have 2 uploaded photos. The query looks like this:
me/photos/uploaded?since=2009-12-31T18%3A30%3A00.000Z&until=2010-12-31T18%3A30%3A00.000Z&limit=200
This query has limit set as 200 , and it correctly returns the 2 photos. But the problem arises when I have a smaller value of limit, lets say 100. So basically a query:
me/photos/uploaded?since=2009-12-31T18%3A30%3A00.000Z&until=2010-12-31T18%3A30%3A00.000Z&limit=100
return me an empty json. Even though there are only two photos, a limit of 100 returns null. Any insights?
I m trying to retrieve the page_fans using the following FQL query (Insights Table).
SELECT metric, value FROM insights WHERE object_id=182929845081087 AND metric='page_fans' AND end_time=1334905200 AND period=86400
But I just get blank data , when I make the above query.
{
"data": [
]
}
I m able to retrieve the other metrics by just changing the metric value in the above query.
For Eg. I get the page_engaged_users by just changing the metric value in the above query.
SELECT metric, value FROM insights WHERE object_id=182929845081087 AND metric='page_engaged_users' AND end_time=1334905200 AND period=86400
{
"data": [
{
"metric": "page_engaged_users",
"value": 35
}
]
}
What is wrong with the first query in which I m trying to retrieve the page_fans ??
And I know that I can retrieve page_fans using other ways as well !!
If you look at the insights documentation, notice in the last column that the page_fans metric is only available for the lifetime period. Change your query to period=0 or `period=period('lifetime') and you'll get data.
If you want the new fans added on a given day, use the page_fan_adds metric with period('day').
If you request any other period, you will either get an error or no data (which means someone other than you can request that metric for a different period).
The other problem could be that you are requesting data that is too recent. In your query, you're looking at 2012-04-20, so you should be fine. When I tested this, I got no data if I used a date greater than 2012-09-15 (on 2012-09-18).
Given a page access token, how can get the total number of posts day by day?
You can query the FQL insights table: http://developers.facebook.com/docs/reference/fql/insights/
the insight you're looking for in in the Page Content section of that link.
However, that is an insight that is being deprecate on 2/15. So be sure to get your data quick. It's being removed from Facebook. I don't know why.
You can only retrieve a summary/count for published posts on a page. Something like this will work when querying the Page directly:
{PAGE}?fields=published_posts.limit(1).summary(total_count).since(1)
The response will look something like:
{
published_posts: {
summary: {
total_count: 12345
},
...
}
}
or if you want to query the published_posts directly, use:
{PAGE}/published_posts?limit=1&summary=total_count&since=1
The response will look something like:
{
summary: {
total_count: 12345
},
...
}
Setting limit to 1 ensures that your query is not unnecessarily large. If you're just needing the total post count, then set limit to 1.
The since parameter is a unix timestamp (milliseconds since January 1, 1970) and is required to retrieve the total post count. Set this to 1 as setting it to 0 will throw an error.
More details: https://developers.facebook.com/docs/graph-api/reference/page/published_posts/