Is it possible to implement friends.getMutualFriends using FQL? - facebook

I am looking for a way to implement friends.getMutualFriends of Facebook's Old REST API with FQL. The reasons are twofold:
1. getMutualFriends only returns a list of IDs, and I'd like to use a multi-query to fetch additional information for each returned ID (rather than make additional calls to Facebook)
2. I'd like to batch a few such calls together. batch.run is a bit limited (20 calls) and presumably slower than a multiquery.
Unfortunately, I probably can't use the friends table, because while the sourceID is of a user of my app, the targetID may not be a user of my app (Facebook won't even let me select the friends of the target even in a nested query, which is understandable due to privacy concerns.)
But since I can get the mutual friends using friends.getMutualFriends, I'm wondering if there's any FQL equivalent.

Related

How to pull ad insights in bulk using Facebook Graph API?

I am trying to do what I thought would be a very simple task which is to use the Facebook API to retrieve insights about ads, but I'm having so much trouble. I know how to use multiple API calls to retrieve the list of ads, and then retrieve the insights for each ads using an API call for each one.
However, I'm limited at 200 API calls per hour, so this is no good if I wanted to pull all ads from all-time. There is a way to batch call the ad insights using an endpoint like:
act_XXXXXXXXXXXXXXX/ads?fields=insights{cpc, impressions}
But then I am unable to specify the timeframe so it only grabs stats from the past month. Usually I would specify the timeframe with a field of
date_preset=maximum
(or whatever I want the date_preset to be), but in this case if I add it as another field it does not affect the the insights (I presume since they are using those brackets as a special way to pull the bulk insights).
I swear to god if I figure this out I'm releasing it publicly and loudly for free because I think it's ridiculous that this is so roundabout.
Do this: act_XXXXXXXXXXXXXXX/ads?fields=insights.date_preset(maximum){cpc, impressions} This is called a nested query.

Requesting posts of a facebook group

I am looking to create a product that retrieves the posts of a public facebook group (viewable to non-members) and analyse that data based on (from necessary to useful) posts (as strings to be processed), like count, different reaction count and possible geotag data. I am confused by the process of application, as I cannot use the group api without already having an approved app and such - is there a way to retrieve and work on data in python/java/js without actually creating an app, for testing purposes?

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?

Read all ad campaign from Facebook Marketing API

I'm using Facebook Marketing API to get ad campaingn from Facebook. I'm getting the data, but the problem is, they are sending the data with pagination. I have the url for the next set of data, so I need to call the Facebook API multiple times. I can set the data limit in the request to a huge number so that I can get all the data at a time.
Is there any other option to get all the data?
I tried with until & since parameter and sending the timestamp of current time & 0, but it didn't worked.
So is there any other way out?
Paging through the data is the way to go. There is no alternative.
There are indeed different ways to use paging, one of which would be to use the next/previous links provided in a response. Another way is to use so-called Cursor-Based Pagination, where you construct your own next/previous links using a provided cursor tokens. This is documented here.
Please not that you can indeed change the requested limit to some huge number, but Facebook's API may silently reduce that number to whatever it thinks is sensible, or it may return an error saying that you requested too much data. Summarized, this means you will need to use paging.

Facebook social network analysis on my page's comments/shares/likes

Let me explain the whole thing here so you can have a clear picture of the situation:
I have a page on facebook and the insights (both on the page and from the graph api) give me a lot of valuable information, but I need to go deeper. I was thinking of applying the social network analysis concepts (centrality, betweenness, eigenvector, etc) on who likes/shares/comments on my pages posts/pics/etc, so I can find the key-users of my page and how virality spreads among them.
Lets take 'liking a post' as an example. First thing I need is to get a list of everyone who liked that post, which is simple and can be done with a few requests to the graphapi. Now comes the tricky part: I need to know the relationship between all these people who liked the post, but I don't have access to their friendlist. To have access to the friend list I'd have to make the page an app and request that permission, which can't be done at this point. But facebook api allows you to check if two individuals (user1 and user2) are friends with a request like this: user1/friends/user2, and for that I don't need special permissions, just a regular token. Well, so far so good, I just get the users who liked the post and check two-by-two which ones are friends. But here comes the problem:
I can make batch requests to the API, which means I can check 50 pairs of users with one request. And from what I read, facebook allows 600 requests each 600 seconds. Simple math: 30,000 pairs of users each 10 minutes. It's a big number, should be enough. It isn't. Let's assume that the post has 1,000 likes (not being optimistic at all). I'd have to check user1 against the other 999 users. Now user2 would have to be checked against the remaining 998 users (no need to check against user1 again, because the friend-check works both ways). User3 against 997 users and so on, until user999 needs to be checked against 1 user. Therefore I'd need to perform 999+998+997+996+...+3+2+1 checks, or 499,500 requests, which means almost 3 hours to get the data obeying facebook limitations. 10k likes would take over a week!
So my question is: is there any other way to make this work? Another way of getting data, or a largest batch request? Some way I can retrieve this data? Or it's just impossible, since facebook retains the important information?
Thank you for reading all this and helping me out ;)
What you are trying to get to is information that Facebook does not want easily available.
In the same way that you don't have access to "friends of friends", trying to reconstruct social connections takes far too many calls to the API since, as you stated, you would need to test against individual pairs.
Whilst your question is valid and from what I can tell you are not trying to obtain this data to to perform some malicious actions, I'm afraid that at this point you'll just have to use the data that Facebook makes available to you through the Insights application and the access to that data though the API as well.