fb:comments-count return wrong value - facebook

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.

Related

getting full number of comments of facebook status in API v2.6

How to get number of all comments (number of status comment + number of comments of comments) without looping over every comment?
This parameters show only number of direct comments of status, without nested comments
?fields=comments.summary(true).limit(0)
How to do it similarly to FQL?
FQL requests have no problem with it
SELECT id,likes,post_fbid,time,fromid,text,text_tags,parent_id FROM
comment WHERE post_id = %post_id%
it returns all comments (nested or not) as is. easy to count and easy to check of something changed
Found an answer: you should use filter = stream
likes this
?fields=comments.summary(true).filter(stream).limit(0)
It's in the official documentation, but was not very obvious to me, that it can be used in object endpoint and not only in object/comments.
https://developers.facebook.com/docs/graph-api/reference/v2.6/object/comments#readmodifiers

FQL: Get comment data WHERE object_id={a known object_id} works, but WHERE id={a known comment XID} does not?

I'm using FQL to get comment data from webpage with a Facebook comment box. I use the graph to get the object_id, then use FQL to get all comments with that object_id. However, if I want to pull data from a specific comment using its id (sometimes referred to as an XID) the FQL returns 0 results.
According to https://developers.facebook.com/docs/reference/fql/comment/ the id should be indexed, so this query should work:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+id={some known XID}
But it doesn't. BTW, THIS query does work:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+object_id={some known object_id}
It is irritating how I can't pull query for comments using time or fromid or anything other than object_id, id, post_id, and parent_id... but in practice only using the object_id returns anything.
has anyone else run into this problem? Is my XID query wrong somehow, or is the id only indexed on certain kinds of comments, and not webpage comments for no inexplicable reason?
This one I managed to solve with trial and error. I had to put the id in single quotes. It's odd, I could query the object_id without putting it in quotes, but not the id. This is sort of what the working FQL looked like, except with a valid access token:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+id='#########_####'
as opposed to:
SELECT+id,+text,+time,+fromid,+is_private+FROM+comment+WHERE+id=#########_####
which failed to return any results.
Thanks for being consistent, Facebook :(

Querying all public facebook posts

I need to build an application that will have three input fields for three URLs. Application then needs to search all public posts on facebook and find users who posted that specific URLs. I'm using this code:
$q = "http://www.someurl.com";
$search = $facebook->api('/search?q=' . $q .'&type=post&limit=200');
foreach ($value as $fkey=>$fvalue) {
if(isset($fvalue['from']['name']))
{
echo $fvalue['from']['name']."<br />";
}
}}
This prints out 200 facebook user's names that posted one specific link. But, as I mentioned above, I need to search for multiple URL match. By using this approach, I would need to make three query calls and then cross-reference results and get users that appear on all three result lists. Is there any way to form query to return needed results in just one call? I now that FQL is powerful tool, but I think that it cannot be used for this kind of public queries. Am I really limited only to public graph api? And if that is the case, is it possible to form complex query using only graph api?
EDIT#1:
I tried using following FQL:
SELECT source_id FROM stream WHERE
CONTAINS('http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic')
AND CONTAINS('http://kotaku.com/5917693/ten-years-of-civ-ii-lock-the-world-in-perpetual-war')
AND CONTAINS('http://www.youtube.com/watch?v=1TBxdXm3DP0') limit 200
As I understand, this should return users who have these three links in their fb stream. However, that is not the case. Am I getting this all wrong?
A simpler approach will be to just check the presence of a URL in the message part of the Post. This fql should work:
SELECT message FROM stream WHERE CONTAINS("http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic")
AND strpos(message,'http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic') >=0
Similarly, to search for a post containing all three links you can extend the fql further.
SELECT message FROM stream WHERE CONTAINS("http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic")
AND strpos(message,'http://www.incgamers.com/2013/12/doom-20th-anniversary-today-true-classic') >=0
AND CONTAINS("http://kotaku.com/5917693/ten-years-of-civ-ii-lock-the-world-in-perpetual-war")
AND strpos(message,'http://kotaku.com/5917693/ten-years-of-civ-ii-lock-the-world-in-perpetual-war') >=0
AND CONTAINS("http://www.youtube.com/watch?v=1TBxdXm3DP0")
AND strpos(message,'http://www.youtube.com/watch?v=1TBxdXm3DP0') >=0
it is no longer possible since facebook disabled public post searching in mid December 2013.

How to get (better) demographics for fans of a Facebook page?

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.

Facebook - max number of parameters in “IN” clause?

In Facebook query language(FQL), you can specify an IN clause, like:
SELECT uid1, uid2 FROM friend WHERE uid1 IN (1000, 1001, 1002)
Does anyone know what's the maximum number of parameters you can pass into IN?
I think the maximum result set size is 5000
It may seem like an odd number (so perhaps I miss counted, but it's close ~1), but I can not seem to query more than 73 IN items. This is my query:
SELECT object_id, metric, value
FROM insights
WHERE object_id IN ( ~73 PAGE IDS HERE~ )
AND metric='page_fans'
AND end_time=end_time_date('2011-06-04')
AND period=period('lifetime')
This is using the JavaSCript FB.api() call.
Not sure if there is an undocumented limit or it might be an issue of facebook fql server timeout.
You should check if there is a error 500 returned from FB web server which might indicate you are passing a too long GET statement (see Facebook query language - long query)
I realized my get was too long so instead of putting many numbers in the IN statement, i put a sub-query there that fetches those numbers from FB FQL - but unfortunately it looks like FB couldn't handle the query and returned an 'unknown error' in the JSON which really doesn't help us understand the problem.
There shoud not be a maximum number of parameters as there isnt in SQL IN as far as I know.
http://www.sql-tutorial.net/SQL-IN.asp
just dont use more parameters than you have values for the function to check because you will not get any results (dont know if it will give away an error as I never tried to).