How does the Facebook Graph API public post searching works? - facebook

I've started working with Facebook Graph API this month and I'm currently experiencing some odd behaviors with it.
To start, I'm using the Graph API 1.0 (which supports public post searching), with queries such as those below.
https://graph.facebook.com/v1.0/search?q=foo bar&type=post
https://graph.facebook.com/v1.0/search?q=foo&type=post
The weird behavior in this case is that the first query returns almost the same number of results that the second one. Thus, no matter how "vague" my query is, I'm getting a limited number of posts (yeah, I'm already considering pagination).
So how does this work? The Graph API Documentation isn't clear about this subject, so any clarification would be really appreciated.
As I understood so far, Facebook does not return all public posts containing the researched terms. Some old questions here in StackTrace support this assumption (example)
Different apps or different users may retrieve different results (which is another "odd" behavior I found). (example)
Am I correct? If so, is there ANY way to improve my recall? Any paid services from Facebook or specific permissions that I should get for my app? Searching from multiple views (users or apps) would help? Is there any way to query only recent results and therefore obtain more results?
Thank you.
P.S.: I'm aware that Facebook has been planning to remove this functionality by 2015, but for now it's working and I wanted to give a try :-)

Related

how to get facebook search results

I am trying to build a network of people that match a search criteria on FB and get their friends. All public information of course, or at least accessible to my own account. Say I search for the name "Smith".
I want to get all the people that match that query, then search in their connections all those names that match "Smith" and the relationship to each others and so on. This way I create clusters of the various interconnected "Smith"(es).
I am fluent with R and so I tried the Rfacebook package. There is a function there called searchFacebook but it does not work anymore, because the API search was disabled by Facebook itself. for info I get:
Searching for posts was deprecated with version 2.0 of the Facebook Graph API.
What options do I have in this case? Is this even possible?
The language is not an issue, I can use Python too. I just used R cause it's faster for me.
Thanks

How can I search for taggable_friends (FB API) form within my app without using a limit on my request?

I am currently using Facebook's OpenGraph to obtain taggable_friends. By default and as of FB API > 2.1 the request only returns 25 objects. You can add a limit and increase your data response but you have no parameters you can pass. It just doesn't feel right to increase the limit with a hard coded number. So, one of the features of that app is that you can search for taggable_friends and select them. If you return a large limit to obtain (in most cases) all of your friends can take a while. Let's say you only get the first 25 and you search for a person that is in a batch - you don't know where. Since you have no parameters to pass to your request, a searchTerm for your your API call is out of the question.
Has anyone ever done a batch call? Facebook allows for multiple requests using some sort of batch calls. How would that look like in JS code?
I can use my users information to obtain the amount of friends he/she has and set a reasonable limit. That helps in the majority of cases but doesn't solve the problem.
Did someone ever encounter that problem and solved it?

Can only access sharedposts for some Graph API objects?

I have an access token for a page on Facebook. I can view that page’s feed, and individual posts in that feed. But for some reason, I can only request the /sharedposts endpoint for some of them using v2.2 of the Graph API.
The access token has the user_posts and read_stream insights. When I request the shares field I can see more than one post with shares, but when I request [POST_ID]/sharedposts for some of them, I just get an empty data array in response.
Why is this? Are there some gotchas I should be aware of? It’s a tad frustrating that the /sharedposts edge will return returns for some posts but not others using the same access token and API version.
This is a know bug, which still seems to be unsolved.
Basically it should work like you expected, but even with all necessary permission (and even for public posts) it does not return the object with each of the shares.
You probably want to subscribe to the bug here to be noticed once it has been solved:
https://developers.facebook.com/bugs/1404733043148335/
I just posted my insight/workaround for this bug on the bug report that lars.schwarz linked to, but I'll paste it here as well:
/sharedposts will only retrieve public posts or posts from users who have granted your app access. HOWEVER, the endpoint does not seem to query for this intelligently. I'm not sure, but I think the endpoint has a default limit of 25 results. What appears to be happening is that the endpoint queries Facebook's database for 25 posts, then filters that set based on your app's permissions.
What this means is that if the most recent sharedpost your app is allowed to access is 30 posts deep, the endpoint will return an empty data set. If your app is allowed to access one post which is 15 deep, and one that is 30 deep, it will only return the post that is 15 deep.
In order to get around this, you can set a really high limit (I've been using 2000). The problem with this is that if your post has more than 2000 shares, you will still miss stuff. You can't make the limit insanely high, unfortunately, because the endpoint will return an error telling you to query for less data (even if the query would only actually return a handful of posts). Therefore, I've been setting a limit of 2000 and using the "until" parameter to move through the sharedposts chronologically.
Hopefully that helps clear things up. This is a major pain, and an imperfect solution (although it gets 99% of the job done I think). I encourage everyone to file a bug report on this here: https://developers.facebook.com/bugs
It appears that this bug has been around for years, and I was told yesterday that they have no short-term plans to fix it. If we file enough complaints, maybe they'll prioritize it higher.

Getting number of people who like a page on facebook by city

A question than has been floating around is how to get the list of IDs of people that like a page (here, or here, for instance). From previous answers (and reading the FB API docs...) I am convinced that to be impossible.
However, that is not what I'm after. I don't need the user_ids at all. I just need the number of likes of a page, per city (or some subdivision of a country). There is a field for a Page for the total number of likes, which obviously isn't enough. Insights should provide this, but while page_fans_country works ok as the info is public, page_fans_city returns no results, so I'd need a different way of getting the information.
Is there a query (or set of queries) that would work? Either Graph API or FQL would be fine, at this point.
As to your first statement, I have found that to be correct aswell. My current solution includes, as it has to, external storage.
On to your actual question, it is possible via the Insights API you've found yourself. Rather than moving on from page_fans_city (because it returns no results), you should find the issue. Most likely, you're using a User Access Token without the scope manage_pages, which prevents it from becoming a Page Access token. You should also include read_insights. Read more here. For further information about the object/insights go here.
Hope this helped.

Read my Facebook application's publish stream posts

I created a number of posts on behalf of the user by issuing an HTTP POST request to (PROFILE_ID/feed) with the publish_stream. Sample:
https://graph.facebook.com/me/feed?
I got everyone's post ids, but I when I'm trying to access and read them I getting a "false" respond..
I was at a Perl Mongers meeting (Los Angeles) last week where the presentation was on integration with Facebook. In particular, one of the developers was discussing his new module, Facebook::Graph. He indicated that in producing the module he learned a lot about what Facebook would do if you request information but don't provide everything it is expecting in your request. Your problem description sounds like a case in point.
The module's description is:
This is a Perl interface to the Facebook Graph API
http://developers.facebook.com/docs/api. With this module you can
currently query public Facebook data, query privileged Facebook data,
and build a privileged Facebook application. See the TODO for all that
this module cannot yet do.
There is a companion POD for that module called Facebook::Graph::Cookbook. It contains a couple of cookbook examples.
While the module is still fairly new and under development, I know that the individual who worked on it has spent many hours working on it in a professional setting where solid results are expected. I'm confident that he "got it right." It's currently being used by a high-traffic well known website.
There's no point trying to re-implement interfacing with this API when someone else has done a good job of it already. Through the discussion that took place after the presentation I know that the module has gone through extensive testing. That's not to say it's perfect, but it's probably a hundred or more man-hours further along the journey.
It's my suggestion that you implement your Facebook Graph interactions through using this module. I suspect when you do, many of your headaches will go away.
You'll need to ask for the read_stream permission to do this