2012-03-18 127 views
1

我想構建一個將消息發佈到爲應用程序註冊的人員的牆上的FB應用程序。 有兩種設置:API上的帖子數量限制

  1. 一個消息給許多人(1-多,可能發生一天幾次)
  2. 許多用戶特定的按摩(1-1,但其中許多人,可能會發生一些每個用戶每天一次)

總而言之;一個用戶每天可以在他的牆上得到幾個不同的更新,但它可能會影響到很多用戶(這幾乎是我的想法的整點) Facebook將允許我這樣做,並且不會想到我會發垃圾郵件。

PS: 我沿着這個職位,這似乎仍未解決來... ...: Post on Multiple Friend's Wall

和這個職位,不說清楚,我是否我的想法是我應該開始或不;) Graph API post to wall limitation

回答

0

您可以使用Facebook批處理API來做你的意圖。

你可以得到在Facebook上批量要求的更多信息:http://25labs.com/tutorial-post-to-multiple-facebook-wall-or-timeline-in-one-go-using-graph-api-batch-request/

$batchPost[] = array(
    'method' => 'POST', 
    'relative_url' => "/{ID1}/feed?access_token={ACCESS_TOKEN_FOR_ID1}", 
    'body' => http_build_query($body)); 
$batchPost[] = array(
    'method' => 'POST', 
    'relative_url' => "/{ID2}/feed?access_token={ACCESS_TOKEN_FOR_ID2}", 
    'body' => http_build_query($body)); 
$batchPost[] = array(
    'method' => 'POST', 
    'relative_url' => "/{ID3}/feed?access_token={ACCESS_TOKEN_FOR_ID3}", 
    'body' => http_build_query($body)); 

$multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST'); 
+0

我以前沒有見過批量APi,很棒的功能!根據[link](http://developers.facebook.com/docs/reference/api/batch/),它的限制目前是50.假設我有1.000個不同的用戶,那麼我必須將這個帖子分散到20個請求(儘可能短的「間隔」)。這會成爲一個問題嗎? – Planetcrypton 2012-03-19 20:59:53

+0

我不認爲這會是一個問題..您可以使用20個請求發佈到1000個用戶..但始終記住不要垃圾郵件用戶..在我提到的博客文章中,你可以找到更多關於問題。實際上,該帖子中的腳本會執行多個批量API調用,以發佈給50多個朋友。 – 2012-03-20 02:16:21

+0

就我而言,所有的用戶都沒有(nescasarily)相互關聯。我只需要發佈一堆不同的ID。根據[這個論壇帖子](http://forum.developers.facebook.net/viewtopic.php?id = 56950),您可以在600秒內撥打600個電話(因爲他們在2010/2011年回覆)。所以這意味着理論上可以在10分鐘內製作50 * 600 = 30000個帖子......天哪! – Planetcrypton 2012-03-20 08:32:34

0

我開發我的網站http://www.cefozyt.com一個應用程序,它可以發佈鏈接,郵件等多個Facebook用戶牆&組。我使用: -

if($ user){ //繼續知道您有一個擁有有效會話的登錄用戶。

// =========使用PHP-SDK在Facebook Graph API上的批量請求======== //將您的方法調用保存到數組中 $ queries = array ('method'=>'GET','relative_url'=>'/'.$user), array('method'=>'GET','relative_url'=>'/'。用戶。 ''/'朋友'), array('method'=>'GET','relative_url'=>'/'.$user.'/groups'), array('method'=>'GET','relative_url '=>'/'.$user.'/likes'), );

// POST your queries to the batch endpoint on the graph. 
try{ 
    $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST'); 
}catch(Exception $o){ 
    error_log($o); 
} 

//Return values are indexed in order of the original array, content is in ['body'] as a JSON 
//string. Decode for use as a PHP array. 
$user_info  = json_decode($batchResponse[0]['body'], TRUE); 
$friends_list = json_decode($batchResponse[1]['body'], TRUE); 
$groups   = json_decode($batchResponse[2]['body'], TRUE); 
$pages   = json_decode($batchResponse[3]['body'], TRUE); 

// =========過使用PHP-SDK Facebook的圖形API批次請求結束=====

if(isset($_POST['submit_x'])){ 
    if($_POST['message'] || $_POST['link'] || $_POST['picture']) { 
     $body = array(
      'message'  => $_POST['message'], 
      'link'   => $_POST['link'], 
      'picture'  => $_POST['picture'], 
      'name'   => $_POST['name'], 
      'caption'  => $_POST['caption'], 
      'description' => $_POST['description'], 
      ); 

     $batchPost=array(); 

     $i=1; 
     $flag=1; 
     foreach($_POST as $key => $value) { 
      if(strpos($key,"id_") === 0) { 
       $batchPost[] = array('method' => 'POST', 'relative_url' => "/$value/feed", 'body' => http_build_query($body)); 
       if($i++ == 50) { 
        try{ 
         $multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST');       
        }catch(FacebookApiException $e){ 
         error_log($e); 
         echo("Batch Post Failed"); 
        } 
        $flag=0; 
        unset($batchPost); 
        $i=1; 
       } 
      } 
     } 
     if(isset($batchPost) && count($batchPost) > 0) { 
      try{ 
       $multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST'); 
      }catch(FacebookApiException $e){ 
       error_log($e); 
       echo("Batch Post Failed"); 
      } 
      $flag=0; 
     } 

    } 
    else { 
     $flag=2; 
    } 
} 

} ?>

+0

請編輯你的答案和格式的代碼,使其可讀性。 – kleopatra 2013-01-18 12:39:22