How to search Facebook's "invitable_friends" results - facebook

I have a Facebook app, and I'd like to allow my users to invite their Facebook friends to my app. The proper endpoint is /me/invitable_friends which is working well. But towards the bottom of that doc page, they recommend implementing a "search box" to filter the results, yet they don't offer any example of how to do this. I've searched around and haven't found anything.
It doesn't appear as though you can pass additional params for filtering the results. Obviously I can filter the results after the fact, but that's not scalable since the API only returns ~20 users at a time. That limit is modifiable (I believe), though it's of course not wise to bump it too high.
So how can I build a search box interface if I can't pass the search text to the endpoint? I must be missing something.
Thanks in advance.
PS - I'm using the JS SDK.

You should probably file a bug.
Based on the documentation the default size is 1000 records (average Facebook friend list size is 300-400)
If you don't see the next parameter at the end of the result under paging then there are no more results.

Related

How to get more than 100 retweets of the specific tweet?

I use Twitter REST API. Is there any way to get more than 100 retweets of the specific tweet? The default methods may return only 100 retweets.
Ok. GET statuses/retweets/:id does not allow pagination, indeed.
You could consider getting the retweets indirectly, in the following way:
You do a GET search/tweets making sure that you include in the query some keywords of the tweet for which you want to get the retweets
You filter the output in order to find your tweet
However, you are going to find quite a few problems:
Depending on the content of your tweet, it might be difficult to find it with this method. In any case, you'll have to paginate and to use the max_id parameter, as explained here
If you have to paginate a lot or if you have a big number of tweets that you need to know the number of retweets, you will face twitter rate limits. For how many tweets you want to do this? You will need to take into account that you will only be able to do 180/450 per 15 minutes (depending on the type of authentication)
And finally twitter does not guarantee that you are going to get all tweets, in particular if they are old (where old could even mean "older than a week"). So it might be you don't find more than 100 retweets just because the api is not providing the ones you are interested in
In conclusion: I'm not sure it is worth it! Instead, when you collect your tweets, you would need to make sure that you get the retweets as well (or for that matter, any other parameter you need). When you collect tweets, you do it either with the REST api or the Streaming api and you can get it from there.
Hope it helps.

Get old Facebook posts from public FB page

For a university research project I need to view some old posts on public Facebook pages from a specific date range (January 22-31 2014.) I was planning just to copy and paste each post but I have run into a problem with some of the pages that generate a very high volume of posts. Facebook will not display past a certain date. Even with scrolling down, at a certain point the posts stop displaying (this is true by month, so it jumps from January 25 directly to December 31 for example).
Here are the pages I am interested in:
https://www.facebook.com/Syrian.Revolution
https://www.facebook.com/Syrian.Truth
I have read about Facebook's Graph API but have had some trouble using it (I don't have a developer's background.) Also the posts are mostly in Arabic so that may be a problem.
I just need the pages' posts, not the comments sections.
Thanks anyone so much for your help, it is very appreciated.
Really depends on what language/environment you're using. As a simplest case, you can just use Graph API Explorer (https://developers.facebook.com/tools/explorer) and make a call:
{{page_id}}/posts
There are a lot of ways you can improve this call for your benefit. For example, you can use a limit parameter to increase the default number of results it retruns.
{{page_id}}/posts?limit=200
By default, this returns a lot of fields, you can limit the fields.
{{page_id}}/posts?limit=200&fields=id,message,created_time
You can visit https://developers.facebook.com/docs/graph-api/reference/page/feed/ to find out which fields are supported.
In order to get results during a certain time-range, you can use the created_time field to determine if a post belongs to a certain time interval.

Best way to get all the posts on a group's wall on Facebook

There is a group on Facebook called Pointless Haiku. I would like to download all of the posts that have ever been posted to the group's wall so I can entertain myself with random haiku for hours. So far I have used the graph explorer with this fql query (is that the right terminology?): 2204535003?fields=feed.limit(10000).fields(message), and it gives me some of the wall posts but not all of them (not even the first 10000, which is the limit I set). I don't have a Facebook app, because the only reason I want to do this is to amuse myself. Once I get all of the posts I'll probably just write them to a file and do some postprocessing with Python.
What is the best way to accomplish this? Do I need to create an app just to do this, if I want to do it programmatically?
About your observation that it gives me some of the wall posts but not all of them (not even the first 10000, which is the limit I set)
I think that the Graph Explorer is meant to be a development and debugging tool (sort of like Python's IDLE) rather that a full-power query engine. As such, I believe that it has its own built-in page-size limit that cannot be over-ridden. I believe that limit is 25. Note that this is not the limit of the number of results that are returned. It is the maximum number of results that will be displayed on one page. Depending on the size of your results set, it may take several, or many, pages to display the entire set.
So... if you are in Graph Explorer, and run a query, and get back your results, if you scroll down to the bottom of the results produced by Graph Explorer, you may see something like this:
"paging": {
"previous": "https://graph.facebook.com/...",
"next": "https://graph.facebook.com/... "
}
If you click on the URL following the "next" label, it will take you to the next page of results. And if you keep doing that, eventually you will click your way through all of the pages with all of your results.
I think that the way to get ALL of your results at a single shot is to submit the GET request (which Graph Explorer has helped you to create and debug) programmatically via (say) a Python script, or some other kind of script.
Just as an example, I used this query to get back a list of all of the messages and comments posted to a Facebook group since January 1, 2015. (I ran this query successfully on May 8, 2016, using Graph Explorer v2.6.)
128791213885003/?fields=name,id,description,owner,feed.since(2015-01-01){message,created_time,comments{from,message,created_time,comments{from,message,comments{from,message}}}}
I hope this helps.
You can use Graph Explorer for that.
/me/groups can bring group ids
/group-id/feed will bring groups feeds
Don't forget to Get Access Token with user_groups permission.

How to access links provided on one's timeline?

I would like to have access to the links one shared on their timeline.
Using the API Graph Explorer, I see there is a way to access "links". However, it returns empty data. I believe that this might have been used when posting links in FB was done in a special way, different than posting "usual" status.
Then, I thought, I should probably get all the stream and filter the data for links. But at that point, I'm a little confused:
There are THREE different actions that seem to provide the very same data:
- https://graph.facebook.com/me/feed
- .../me/posts
- .../me/statuses
Are they actually all the same?
In addition, all seem to provide me information that is not up to date, but is true for some point in the near past. Moreover, I would like to know how I can get the relevant data from the beginning of the FB usage, or at least, for a given period of time.
Do an HTTP Get to me/links to get the most recent links the user has shared.
To limit it to a timeframe, you can do me/links?since=YYY&until=ZZZ.
Or you can use the paging object to get the previous and next url to use to get that other page of data.

Facebook Graph API SEO Comments and Profanity Filter

I'm trying to integrate the Facebook comments left on our site in a way in which the content can be crawled by search engines and also for people (although I highly doubt there will be many) who don't have Javascript enabled on their browser.
Currently our Facebook comments are displayed via the use of the Facebook comment social plugin (using the <fb:comments href="MY_URL" num_posts="50" width="665"></fb:comments> tag). This ends up rendering an iFrame (which are mostly ignored by search engine crawlers) so the plan is to render this information and format it with basic HTML. To do this, the comments are pulled using the Graph API - this is then only be displayed to crawlers and people with Javascript disabled.
This all works nicely using the Graph API call (https://graph.facebook.com/comments/?ids=MY_URL), parsing the JSON result and displaying it on the page. The problem is that the <fb:comments> approach filters our results based on a blacklist we have set up on one of our Facebook Apps. The AppId with the relevant blacklist is stored on the page using metadata (<meta property="fb:app_id" content="APP_ID"/>) which the <fb:comments> control obviously must somehow use to filter the comments.
The problem is the Graph API method does not filter any results as I guess no blacklist (or App Id containing a blacklist) is specified. Does anyone know how to specify a Facebook App ID to the API call URL or of another way to not fetch commnents back that violate the terms of the blacklist?
On a side note, I know the debate about filtering content in comments rages on but it is a management decision to implement the blacklist, and one that I have no influence in changing - just incase anyone felt the need to explain the reasons why content filtering is or isn't a good idea!
Any thoughts on a solution?
Unfortunately there's no way to access a filtered list of comments using the API - it might be a reasonably request to have this in the API - you should file a wishlist item in Facebook's bug tracker
Otherwise, the only solution I can think of is to implement your own filter on your side when retrieving and displaying the comments from the API.
According to the Comments plugin documentation the filter on Facebook's side is implemented as a simple substring match, so it should be trivial to implement.
A fairly simple regular expression match should be able to check each comment against a relatively long list quickly.
(Unfortunately, the tradeoff here is that implementing a filter is easy, but you'd also need to write an interface so that whoever's updating the list of disallowed words can maintain the list for both the Facebook plugin, and your own filtering.)
Quote from docs:
The comment is checked via substring matching. This means if you blacklist the
word 'at', if the comment contains the sequence 'a' 't' anywhere it will be
marked with limited visibility; e.g. if the comment contained the words 'bat',
'hat', 'attend', etc it would be caught.
Pretty sure there is no current way of doing this from the graph API, the only thing I can suggest is taking the blacklist and build your own filter