简体   繁体   中英

how to post to all friends in wall One time facebook api

I want to publish to all people to connect through application Publish all his friends in the wall, this code only publishes its wall What needs to change or add to it will take to his friends list and will publish them in the wall through app

please help me

    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);
            }
    }

This is how you get all of your friends user ids:

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

However, if you try posting to all your friends, Facebook will block your application. What you can do instead is send your friends Requests .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM