1

I want to post on my facebook groups. This is my code:

$access_token = $facebook->getAccessToken();
$info = $facebook->api( '/me/groups', 'GET', array( 'access_token=' => $access_token ) );
$count = count($info['data']);
print "<h2>Alege grupul(".$count.") in care vrei sa postezi:</h2><br>";
$i = 0;
foreach ($info['data'] as $group) {
    $group_name = $group['name'];
    $group_id = $group['id'];
    echo "<input type='checkbox' value ='".$group_id."'>  ".$group_name."<br>";
    if ($i == 0){
        $post_url = '/'.$group_id.'/feed';
        $msg_body = array(
            'message' => 'TEST',
        );
        $postResult = $facebook->api($post_url, 'post', $msg_body );
    }
    $i++;
}

This is the code from the login part:

$loginUrl = $facebook->getLoginUrl(array ( 
                    'scope' => 'publish_stream,user_groups,user_about_me,user_interests,friends_groups,friends_interests,friends_about_me',
                    'redirect_uri' => 'http://facebook.ebis-servicii.ro/mytest/test.php'
            )); 

This is the link , where I am coding now. The result is an interesting error:

Fatal error: Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action thrown....

I'm a totally newbie to this, this is the first time I'm using fb php api, so my question is what am I doing wrong ? Why am I getting this ?

ekad
  • 14,436
  • 26
  • 44
  • 46
Attila Naghi
  • 2,535
  • 6
  • 37
  • 59
  • 1
    `publish_stream` is not available any more – all publish permissions have been consolidated into one permission called `publish_actions`, so you need to ask for that instead. (And all `friends_*` permissions have been completely removed with API v2.0, so no use in trying to ask for those any more.) – CBroe Aug 23 '14 at 23:51
  • that code looks like you want to create a spam app, it is meant to go through every group of the user to post some predefined message. not to mention that the message parameter MUST be 100% user generated. there is no serious situation where you would need to post the same stuff in every single group the user is member of. – andyrandy Aug 24 '14 at 01:28

0 Answers0