Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requesting multiple Facebook fanpage data in a single call

I have about 20 Facebook fanpages setup with a "Welcome/Home" app install across all of them. Is there a way to tally up all the "Likes" from these fanpages to display on my app? I've tried using the JavaScript SDK FB.api() feeding it arrays (using .toString() and .join(',')) as well as JSON objects and even direct input. It seems like Facebook can only handle one fanpage id request for data at a time. I haven't looking yet, but is there a way to do this in PHP. I feel I may run into the same situation.

Suggestions would be great!

like image 570
Smccullough Avatar asked Aug 02 '11 16:08

Smccullough


1 Answers

Graph URL for Multiple Pages - https://graph.facebook.com/?ids=19292868552,11239244970

Multiple Pages Request as a Facebook JavaScript SDK Example:

FB.api(
    '/', 
    {ids : "19292868552,11239244970"}, 
    function(response) { 
        if (!response || response.error) {
            console.log(response.error); 
        } else { 
            console.log(response); 
        } 
    }
);

Multiple Pages Request as a Facebook PHP SDK Example:

$result = $facebook->api('/', 'get', array('ids' => array('19292868552','11239244970')));
like image 120
jBit Avatar answered Nov 15 '22 06:11

jBit