如何发布到墙上的所有朋友一次facebook api

时间:2012-08-12 18:36:46

标签: php facebook api

我想发布给所有人通过应用程序连接发布他所有的朋友在墙上,这个代码只发布它的墙需要更改或添加到它的朋友列表将通过它发布在墙上应用

请帮帮我

    require "../settings.php";
    require '../src/facebook.php';
    require "../fbaccess.php";
    require "web_config.php";


    //user data from database
    $sql = mysql_query("SELECT user_id,user_access_token,user_access_token_expire FROM data_table");

    while ($data = mysql_fetch_array($sql)){
    $user_id = $data['user_id'];
    $accessToken = $data['user_access_token'];
    $accessTokenExpire = $data['user_access_token_expire'];


    try {
                $publishStream = $facebook->api("/$user_id/feed", 'post', array(
                    'message' => "",
                    'link'    => '',
                    'picture' => '',
                    'name'    => 'iOS Apps & Games',
                    'description'=> ''
                    )
                );
                //as $_GET['publish'] is set so remove it by redirecting user to the base url
            } catch (FacebookApiException $e) {
                error_log($e);
            }
    }

1 个答案:

答案 0 :(得分:0)

这就是您获取所有朋友用户ID的方式:

SELECT uid FROM user WHERE (uid IN (SELECT uid2 FROM friend WHERE uid1=me()))

但是,如果您尝试向所有朋友发帖,Facebook会阻止您的申请。你可以做的是发送你的朋友请求