Search facebook group using the name as a search term on Facebook FQL - facebook

I've tried using the Facebook Graph API. But the results came out, it did not show up to 150 groups. I'm not sure that it is a limitation of Facebook or not.
An example URL that I tested.
Now, I would like to test the FQL Query. But did not succeed. I have the following error
(#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
This is a SQL statement
SELECT gid, name, privacy FROM group WHERE strpos(name, "programming") >= 0

Related

Facebook FQL Searching Pages Using Partial String

I'm trying to search for a company's different branches using a partial string. Here's the query I'm using:
SELECT name, location, fan_count, talking_about_count, were_here_count
FROM page WHERE strpos(name, "Applebee's") >= 0 OR (name < 0)
I get the error:
Your statement is not indexable. The WHERE clause must contain an
indexable column.
Name is listed as indexable, so I'm not sure why this error is occurring.
You can use function CONTAINS():
SELECT name, location, fan_count, talking_about_count, were_here_count FROM page WHERE CONTAINS("Applebee's") and strpos(name, "Applebee's") >=0
This query will output all results which will contain Applebee's in name.

FQL search public posts

I'm trying to do a search using FQL.
Using the Graph API, it works but there are more options using FQL.
Using something like
https://graph.facebook.com/search?q=myquery&access_token=mytoken
it work fine.
I'm looking for the equivalent in FQL.
What query I must write in here
https://api.facebook.com/method/fql.query?query=SELECT%20post_id%2C%20actor_id%2C%20target_id%2C%20message%20FROM%20stream&access_token=mytoken
The query above give me that
Parser error: unexpected end of query
I want to search in all public posts.
I've been looking everywhere but I did not found any solution.
Thanks.
For searching public posts for a string, you need to use the Graph API, and then filter those posts in your script. I don't think searching all public posts is possible in FQL. While FQL is more powerful, it is also more limited.
You are getting an error because you don't have a "WHERE" clause in your query. This is required in FQL.
The limit comes in because you must use at least one indexed column in your WHERE query. For the stream table you must specify either a post via post_id, a user via source_id or filter_key, or a live stream via xid. The indexed fields are marked with a * on the documentation site.
For instance, [this FQL][1]
SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key = 'others'
AND strpos(message, 'the') >= 0
will get you all posts that show on your access token owner's wall that have not been posted by the owner, with the string 'the' in them. That is the best you can get. If the post isn't visible on their wall, then you won't get the post.
If you try to leave out an indexed field, FQL will throw a 'Your statement is not indexable' error.
[1]: SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key = 'others' and strpos(message,'the') >=0

Facebook FQL Query, searching on non-indexable item

I would like to generate a list of facebook user id's of people who are not in the United States. Rather than iterating through a list of user id's and checking each locale, I would like to do an FQL query. I attempted to execute this statement:
SELECT uid, name FROM user WHERE locale != "en_US"
However, when I make the query, I recieve the response:
(code 604): Your statement is not indexable.
This is because locale is not an indexable field. Do any of you know what I can do to get around this? Or perhaps another way of doing this entirely?
Thanks in advance!
It says "Your statement is not indexable." That means, you can't just use any query (like, extreme case, SELECT uid, name FROM user to get all facebook users) that does not conform. Only queries that include WHERE on fields that are indexable can be used. It's a policy, you can not circumvent it.

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.

How could I use FQL to query all the events without using indexable column which is marked *

I have a problem to solve.
I want to query all the events and I want to find the specific string.
The FQL code is like the following:
SELECT eid, name, location, start_time, end_time FROM event WHERE strpos(lower(location),'test') >=0
When I used this FQL code,it always occurred error.
The error message is "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"
Please,give me your point of views~thank you :)
Well, the error message is clear:
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
So simply your approach won't work.
EDIT:
To further explain why this is not possible:
Facebook deals with "over than 900 million objects that people interact with (pages, groups, events and community pages)". reference.
So basically giving you (all App devs) the ability to search ALL pages, events, groups...etc will definitely bring the system down. This is why these "indexible" fields are selected carefully.
For instance, if you want to search events by "location" then these events should be "somehow" related to your application. Like created by your App for example, and you should have their ids stored somewhere so that something like this would work:
SELECT eid, name, location, start_time, end_time FROM event WHERE
strpos(lower(location),'test') >=0 AND eid IN (ids_from_your_db)