17

My client company manages Facebook Pages for several thousand small businesses. We've built a Facebook App that for our client to simplify the process and allow them to quickly make changes to many/all the pages in one go.

For whatever set of business reasons our client company has just ONE of their employees added as an administrator (along with the small business owner) for each of these pages. This user account has added our App and we are grabbing page tokens and using those page tokens to manage the page (change the contact info, add a tab, fetch wall posts). We're coming up against some really harsh api request limits. Right now we can only add about 3 new Facebook Pages a minute (which I think requires maybe 6-10 api calls when its all said and done).

I've seen people estimate that a you're allowed about 600requests/600seconds for an access token but I thought that since we were doing most of the work with page tokens our actions wouldn't be counted towards a single api limit.

Does anyone know for sure if the api limits are based on individual tokens even if they technically belong to the same user? Is there any way I can get around this limit considering that I can't really add more admins to these pages?

Tony Bathgate
  • 392
  • 2
  • 13
  • 1
    Sorry I think I was unclear. We aren't creating these pages right now. These pages exist already. At a rate of about 3 pages per minute we are "adding the page" to our system. So we obtain their access token, update their contact info, add a tab, and get the info on the tab. – Tony Bathgate Mar 07 '13 at 19:16
  • 2
    The API call limits should be per session/access token and many large apps are managing hundreds of pages without problems so i don't know why you'd be getting a problem here - are you sure you're not accidentally making API calls with no token, the app token, or the (in place of a page token) admin's user access token? – Igy Mar 11 '13 at 23:23
  • 1
    @Igy: I double checked and this is the workflow. 1) Call to get general page info using our own access token. 2) Call to get the page's access token using the Admin's access token. 3) Call to add the tab using the page's access token. 4) Then we (possibly) kick off an async tasks to set the tab's name on the page using the page's access token. 5) then we kick off async tasks to fetch posts and comments from the page. The problem may be in step 5; we are using the admin's token apparently. Since all these pages have the same Admin I think this is why we go over quota. – Tony Bathgate Mar 16 '13 at 18:22
  • 2
    ... continued: We're modifying how step 5 is performed so that it uses page tokens, with fewer calls (by relying on FQL calls instead of the graph calls, and probably using push notification for new posts/comments). Based on our business logic there are also cases in which we probably don't need to perform step 5 at all. I think this will be a lot better and soon we'll be doing the best we can. So, thanks for the input @Igy. – Tony Bathgate Mar 16 '13 at 18:26

3 Answers3

2

Actuelly its quite simple, you just need to ask for an access token for the PAGE, not the user.

    $mQuery=array('access_token'=> 'SELECT access_token FROM page WHERE page_id = 'page_id,    
                  'album_id'=> 'SELECT object_id FROM album WHERE owner = '.page_id.' AND name = "Timeline Photos"');
    $multiQueryResult = $facebook->api(array('method'=>'fql.multiquery', 'queries'=>$mQuery));

The first line will get you the access token of that user, and the second its just an example for using multiquery, and reduce your calls.

You can use a max of 50 queries in a multiquery

And if you want to do several things with your page, you can use batch request. This is an example for posting a status, you can add more, until 50 batch request in the same call.

$v['body']['message']=htmlspecialchars_decode($v['message'], ENT_QUOTES);
$v['body']['scheduled_publish_time']=strtotime($v['scheduled_publish_time']);
$v['body']['published']='false';
$v['body']=http_build_query($v['body']);
$batch[]=$v;

try {
    $batchresult = $facebook->api("/?batch=".urlencode(json_encode($batch)), 'POST', array('access_token'=>$access_token));
} catch (FacebookApiException $e) {
    echo $e->getMessage(); 
}
echo $batchresult;

Hope this helps.

Julio Popócatl
  • 712
  • 8
  • 16
2

As @Julio Popócatl refered, using a Page Access Token (generated from a long-lived user token) could be a good choice.

These Page Access Tokens once generated correctly, they will never expire, so it is at least one less query you need to run.

The API requests limit is applied to every request, being from user, page, app, whatever. They are always asking something to Facebook schema, whatever the source of the request is.

Using batch requests is a good idea too, as it would be fetching multiple data with one (or less) requests than making each request individually.

Ivo Pereira
  • 3,410
  • 1
  • 19
  • 24
-3

We're coming up against some really harsh api request limits. Right now we can only add about 3 new Facebook Pages a minute

I would not call this a "harsh" limit at all. Image what would happen if a large number of apps would create hundreds or thousand of pages in minutes ... spam Spam SPAM!!1

I've seen people estimate that a you're allowed about 600requests/600seconds for an access token but I thought that since we were doing most of the work with page tokens our actions wouldn't be counted towards a single api limit.

The limit is enforced based on the App ID only. What exactly you are doing with the API and as who (user, page) does not matter.

Is there any way I can get around this limit

Adding a large number of new pages in short amounts of time does sound like spam to me, a lot. I can't think of a good reason why one would want to do that.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • Sorry I guess other info like the question [here](http://stackoverflow.com/questions/5911068/facebook-graph-api-limit-doubt) say "per access token". I guess they meant App access token. – Tony Bathgate Mar 07 '13 at 19:21
  • So in general what I want to do (to quickly make changes to hundreds of facebook pages) is impossible? – Tony Bathgate Mar 07 '13 at 23:59
  • It is not spam, when we are having many people updating many pages all using the same app. The basic issue is that we can not scale. There are more than 3 million Facebook pages, how do they expect a business to scale to 3 million with 600 API calls in 10 minutes – AGrunewald Mar 11 '13 at 17:51
  • It's 600 api calls per access token, use the user access tokens from the users using your app and the page access tokens for the pages they admin – Igy Mar 11 '13 at 19:05