Facebook API: a strange query error 601 - facebook

I get this error while trying to obtain the number of shares and likes of the particular link on Facebook:
{
"error_code":601,"error_msg":"
Parser error: unexpected ''' at position 56.",
"request_args":
[{"key":"method","value":"fql.query"},
{"key":"format","value":"json"},
{"key":"query","value":"SELECT share_count, like_count FROM link_stat WHERE
url='http://www.lrinka.lt/index.php?act=main"},
{"key":"item_id","value":"5963'"}]
}
The link: http://www.lrinka.lt/index.php?act=main&item_id=5963
The API call: https://api.facebook.com/method/fql.query?format=json&query=SELECT%20share_count,%20like_count%20FROM%20link_stat%20WHERE%20url=%27http://www.lrinka.lt/index.php?act=main&item_id=5963%27
Everything works fine with other links.

You are not closing the url parameter field correctly, missing ' at the end of the URL.
Also no need for the "slashes", try the following in the fql.query console:
SELECT share_count, like_count FROM link_stat WHERE url='http:\/\/www.lrinka.lt\/index.php?act=main
Would return the same error, and this:
SELECT share_count, like_count FROM link_stat WHERE url='http:\/\/www.lrinka.lt\/index.php?act=main'
Is valid but would return zero, and finally this:
SELECT share_count, like_count FROM link_stat WHERE url='http:\\www.lrinka.lt\index.php?act=main'
Would return the result expected.
EDIT:
Based on your comment, you are trying to call https://api.facebook.com/method/fql.query?query=QUERY with the format parameter set to json..so you need to encode the query, I used encodeURI:
https://api.facebook.com/method/fql.query?format=json&query=SELECT%20share_count,%20like_count%20FROM%20link_stat%20WHERE%20url='http:%5Cwww.lrinka.ltindex.php?act=main'

Related

FQL like, share, comment count accuracy

Often it seems fql number for a given url like, share, comment, total counts seem to be off.
For example this url
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine
FQL shows:
share_count: 18377
like_count: 16215
comment_count: 8840
total_count: 43432
The graph api shows very different numbers, and if you check facebook widget count on the url itself it has a totally different count.
Anyone knows what is going on and how to get accurate numbers.
When querying link_stat with url you supplied we see the following:
select comment_count, like_count, share_count, total_count
from link_stat where url = 'http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine/'
{
"data": [
{
"comment_count": 10,
"like_count": 55,
"share_count": 18,
"total_count": 83
}
]
}
But when querying link_stat with parent url of site france24.com we see exactly your numbers (weel slightly changed of course, but almost the same). So check you query - maybe you cut the url somehow in you request?
select comment_count, like_count, share_count, total_count
from link_stat where url = 'http://www.france24.com/'
{
"data": [
{
"comment_count": 8840,
"like_count": 16415,
"share_count": 18377,
"total_count": 43632
}
]
}
Perhaps my initial question was not clear, the issue was with 2 forms of the same url returning radically different results in fql, web facebook widget etc. the urls in question are
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine
and
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine/
The URLs are identical except the ending /
The facebook sees the url as a string. Is case sensitive and it matters how you pass it for url. So, for facebook, there are really two different urls :/ The same happens if someone writes Ukraine with "U".
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-Ukraine

Facebook Scribe OAuth is returning "message":"(#601) Parser error: unexpected end of query

This is my java code, and the URL String which I am passing as a parameter. If I copy paste the URL on the browser it works.
String strURL="SELECT post_id, actor_id, permalink, message, impressions, type, likes, comment_info, share_count, created_time , updated_time FROM stream WHERE source_id='<srcid>'";
OAuthRequest authRequest = new OAuthRequest(Verb.GET, "https://graph.facebook.com/fql");
authRequest.addBodyParameter("q", strURL);
service.signRequest(accessToken, authRequest);
Response authResponse = authRequest.send();
System.out.println(authResponse.getBody());
Error Message -
20:12:58,986 INFO [stdout] (http-localhost-127.0.0.1-8080-2) {"error":{"message":"(#601) Parser error: unexpected end of query.","type":"OAuthException","code":601}}
Thanks cpilko. Actually it was my misinterpretation of scribe OAuth. Instead of authRequest.addBodyParameter, I should be using authRequest.addQuerystringParameter.
The code works now, and I am able to receive the response.

Facebook FQL returns "An unknown error occurred" when querying certain URLs

I've suddenly started getting errors with error code 1 and "An unknown error occurred" when using FQL to query the share stats on a particular URL. This only started happening last week at approximately 2013-01-11 02:43:02 +0000 according to my records.
SELECT url, normalized_url, share_count, like_count, comment_count, total_count, click_count FROM link_stat WHERE url IN('http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=331975235')
Here's the URL I'm using to make the query:
http://api.facebook.com/method/fql.query?format=json&query=SELECT%20url%2C%20normalized_url%2C%20share_count%2C%20like_count%2C%20comment_count%2C%20total_count%2C%20click_count%20FROM%20link_stat%20WHERE%20url%20IN%28%27http%3A%2F%2Fphobos.apple.com%2FWebObjects%2FMZStore.woa%2Fwa%2FviewSoftware%3Fid%3D331975235%27%29
Which returns the following JSON results:
{
"error_code": 1,
"error_msg": "An unknown error occurred",
"request_args": [
{
"key": "method",
"value": "fql.query"
},
{
"key": "format",
"value": "json"
},
{
"key": "query",
"value": "SELECT url, normalized_url, share_count, like_count, comment_count, total_count, click_count FROM link_stat WHERE url IN('http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=331975235')"
}
]
}
Normally, I would query several URLs at once, but in this case I narrowed down the problem to this particular URL that is causing the error in a batch.
Any ideas what could be causing this problem? I am assuming this is something internal on the Facebook side since it was working fine until last week. Additionally, the Facebook Platform Bugs tool (https://developers.facebook.com/bugs) seems to not be working and it's sending me back to the developers main page.
This query works now so the error is not reproducible
[{"url":"http:\/\/phobos.apple.com\/WebObjects\/MZStore.woa\/wa\/viewSoftware?id=331975235","normalized_url":"http:\/\/phobos.apple.com\/WebObjects\/MZStore.woa\/wa\/viewSoftware?id=331975235","share_count":6389,"like_count":3383,"comment_count":262,"total_count":10034,"click_count":0}]
The Bugs tool works as well
In the future file a bug to https://developers.facebook.com/bugs

Facebook - How to get the comments of a fb:comment

I need to get the comments posted on a fb:comments widget. Here is what I've tried:
http://graph.facebook.com/comments?id={{ url_of_the_page }} - Returns an empty list
Executing the following FQL
SELECT post_fbid, fromid, object_id, text, time
FROM comment
WHERE object_id IN
(SELECT comments_fbid
FROM link_stat
WHERE url ={{ page_url }}) - Return an empty response with the fql header
I'm beginning to think that this is not possible. Am I missing something or is this indeed not possible?
That is how you do it. What is the url you are trying? For example, this random Techcrunch article works in the same way as you describe:
http://graph.facebook.com/comments?id=http://techcrunch.com/2011/09/20/digg-experiments-with-topic-newsrooms-aggregates-news-by-most-meaningful-stories/

Determine Object_ID of a URL to use with the Facebook Open Graph

I am trying to learn how to use the Facebook Open Graph API and have a question on how to determine the object_id of my site. I need this object_id so that I can do other queries, such as I want to get a list of users who have liked my site within a given time period.
Based on other Stackoverflow questions I have seen that I should be able to run this query to get the object_id
select id from object_url where url in ('www.bubbasgameroom.com', 'bubbasgameroom.com')
When I run that query it comes back with an empty result. When I run the following query, I see that my page has been liked 21 times
select total_count from link_stat where url in ('www.bubbasgameroom.com', 'bubbasgameroom.com')
What am I missing here? Any help will be greatly appreciated.
Thanks!
Most likely the url should be identical to the og:url meta tag if used on your website. Also you need to append the http:// part for it to work. For example this would work:
SELECT url,site,id
FROM object_url
WHERE url IN (
'http://developers.facebook.com',
'http://www.imdb.com/'
)
Result:
[
{
"url": "http://developers.facebook.com",
"site": "developers.facebook.com",
"id": 113167538713703
},
{
"url": "http://www.imdb.com/",
"site": "www.imdb.com",
"id": 6903354771
}
]
But this doesn't:
SELECT url,site,id
FROM object_url
WHERE url IN (
'developers.facebook.com',
'www.imdb.com/'
)