Note that there are some explanatory texts on larger screens.

plurals
  1. POBatch API, inviting friends
    primarykey
    data
    text
    <p>I'm trying to invite all fans of a page to a facebook event using the batch API. It's the first time I'm using this API, and at this time I have nothing to test this part of code... can someone tell me how to test without using a real page, with real fans... or tell me if it looks correct ?</p> <pre><code> //Getting all the likers of the page $result = $facebookObj-&gt;api(array( 'method' =&gt; 'fql.query', 'query' =&gt; 'select uid,name from user where uid in ( select uid from page_fan where uid in (select uid2 from friend where uid1 = me()) and page_id = '.$fbPage.')' )); //If liker are more than 50 we use batch request if($numLikers &gt;50){ // split array into several part of 50 users accounts $splitLikers = array_chunk($result, 50); // count how many arrays are generated by the array_chunk $countSplit = count($splitLikers); //Start a loop through the numbers of groups of 50 users (or less if last group contains less than 50 users for($a=0; $a&lt;$countSplit; $a++){ //Second loop to go through the 50 likers in one group for($b=0; $b&lt;count($splitLikers[$a]); $b++){ // construct an array containing the whole group $queries[$a] = array('method' =&gt; 'POST', 'relative_url' =&gt; $event_fbID . "/invited/" . $splitLikers[$a][$b]['uid']); } //Send POST batch request with the array above $ret_val = $facebookObj-&gt;api('/?batch='.json_encode($queries[$a]), 'POST'); } }else{ foreach ($result as $value) { $ret_val = $facebookObj-&gt;api($event_fbID . "/invited/" . $value['uid'],'POST'); if($ret_val) { // Success $numInvited++; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload