2012-12-24 40 views
1

我試圖張貼到所有我的應用程序的用戶牆 &,我用這個代碼發佈到只有一個用戶:== >>如何向我的所有應用用戶發佈帖子?

這個代碼僅在一面牆上張貼

<? 

    $config = array(
    'appId' => 'xxxxxxxxxxxxxxxxxx', 
    'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxx', 
); 

    $facebook = new Facebook($config); 
    $user_id = $facebook->getUser(); 
?> 
<html> 
    <head></head> 
    <body> 

    <? 
    if($user_id) { 

     // We have a user ID, so probably a logged in user. 
     // If not, we'll get an exception, which we handle below. 
     try { 
     $ret_obj = $facebook->api('/me/feed', 'POST', 
            array(
             'link' => 'www.example.com', 
             'message' => 'Posting with the PHP SDK!' 
           )); 
     echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>'; 

     } catch(FacebookApiException $e) { 
     // If the user is logged out, you can have a 
     // user ID even though the access token is invalid. 
     // In this case, we'll get an exception, so we'll 
     // just ask the user to login again here. 
     $login_url = $facebook->getLoginUrl(array(
         'scope' => 'publish_stream' 
         )); 
     echo 'Please <a href="' . $login_url . '">login.</a>'; 
     error_log($e->getType()); 
     error_log($e->getMessage()); 
     } 
     // Give the user a logout link 
     echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>'; 
    } else { 

     // No user, so print a link for the user to login 
     // To post to a user's wall, we need publish_stream permission 
     // We'll use the current URL as the redirect_uri, so we don't 
     // need to specify it here. 
     $login_url = $facebook->getLoginUrl(array('scope' => 'publish_stream')); 
     echo 'Please <a href="' . $login_url . '">login.</a>'; 

    } 

    ?>  

    </body> 
</html> 

如何向我的所有應用程序用戶發佈帖子?

請指教!

感謝

回答

0
  1. 獲取所有的應用程序用戶 -

    隨着FQL,只是做:

    $fql="SELECT uid FROM user 
    WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ".$me['id'].") 
    AND is_app_user = 1"; 
    
  2. 循環每一個用戶,並使用飼料

相關問題