1

我想构建一个 FB 应用程序,将消息发布到注册该应用程序的人的墙上。有两种设置:

  1. 一条消息给很多人(1-many,每天可能出现几次)
  2. 许多用户特定的按摩(1-1,但其中很多,每个用户每天可能发生几次)

总而言之; 一个用户每天可以在他的墙上获得一些不同的更新,但它可能会影响许多用户(这几乎是我的想法的全部要点) Facebook 将允许我这样做的范围,并且不会认为我会发送垃圾邮件。

PS:我来了这个帖子,似乎仍未解决...: 在多个朋友的墙上发帖

而这篇文章,并没有让我清楚我的想法是否应该开始;) Graph API post to wall 限制

4

2 回答 2

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');
于 2012-03-18T16:39:59.657 回答
0

我在我的网站http://www.cefozyt.com上开发了一个应用程序,它可以向多个 facebook 用户墙和群组发布链接、消息等。我用了 :-

if($user){ // 继续知道您有一个登录用户,该用户具有有效会话。

//========= 使用 PHP-SDK 通过 Facebook Graph API 批量请求 ======== // 将方法调用保存到数组中 $queries = array( array('method' => 'GET', 'relative_url' => '/'.$user), array('method' => 'GET', 'relative_url' => '/'.$user.'/friends'), array( 'method' => 'GET', 'relative_url' => '/'.$user.'/groups'), array('method' => 'GET', 'relative_url' => '/'.$user. '/喜欢'), );

// 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 Graph 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;
    }
}

} ?>

于 2013-01-18T12:20:07.470 回答