Since I wrote tutorial Post to Facebook Page Wall, few people have asked me to write a tutorial that will post messages on Group wall as well. If you look at previous examples, you should be pretty clear how everything works, posting message or link works very similar way as before, by issuing HTTP POST request to the GROUP_ID/feed.
Before we begin, I suggest you have a look at this article : Post to Facebook Page Wall, I have only made few modifications to that previous examples, which are explained below:
Listing user Groups
To get user group information, user must allow user_groups permission. Once this permission is granted, your application can acquire user group information using FQL (Facebook Query Language). If you look at index.php, you can see I have modified FQL to list all groups where user is a member.
[cc lang=”fql”]
select gid, name from group where gid IN (SELECT gid FROM group_member WHERE uid=23430809234)
[/cc]
To list only groups where user is administrator :
[cc lang=”fql”]
select gid, name from group where gid IN (SELECT gid FROM group_member WHERE uid=23430809234 AND administrator=’true’)
[/cc]
Post Message
Posting message to groups works similar way as posting to user pages wall. Difference here is, we use Group ID instead of Page ID in $post_url.
Dear, I want to share my post links in all groups where I am connected. I modifies your scripts.
I got this error.
It looks like you were misusing this feature by going too fast. You’ve been blocked from using it. Learn more about blocks in the Help Center.
I used below stated info, but this time I am not getting post image. Only text is posted.
$link = "https://www.facebook.com/video.php?v=1785812478309779";
$userMessage = "This Amazing Commercial Random Act Of Kindness From Thailand Will Make You Cry #EmotionalAdvertisement #AmazingCommercial";
Please help for this.
Hello guys, I'm just wondering how to do this
I've created a facebook app and I'm having problems getting the correct permissions.
How did you guys get those permissions for your apps?
Does this require the Facebook App to be approved for the "user_groups" permission?
I read in this documentation here: https://developers.facebook.com/docs/facebook-login/permissions/v2.0#permission-user_groups
"Provides access to the list of groups the user is a member of as the groups connection. This permission is reserved for apps that replicate the Facebook client on platforms that don’t have a native client. It may only be used to provide people with access to this content. It make take up to 14 days for your app to be reviewed."
Did you have to go through that waiting process in order to be able to post to groups? Or is all that is needed is for the user to grant that permission?
Thanks,
Daniel
Hallo Saran, can u please help me for publishing into a group via PHP script ?
I'm a baby programmer in PHP but i cannot understand well FB Apis....
I've a PHP script that publish (via cron job automatically) on a group (it's a group of mine, i'm the admin) a news everytime a new one comes
Togheter the news, it post an image.
I have to say that all worked perfectly since the new facebook restiling (some days)
at the moment the news is published, but the image doesn't.
this is the script i'm using (i modified a lot of time an old script i found times ago in the net).
Can u kindly help me to correct in a such way that it works ?
P.s.
the image that is not published is the $image passed in the function (7° value, the value is the url of the existing image into the server)
THANKS THANKS THANKS THANKS THANKS
function posta_facebook( $messaggio , $titolo , $caption , $link_name , $action_link , $testo , $image, $dest_post) {
// Integrare la Facebook Library
// include ("Facebook-Platform");
$config = array();
$config['appId'] = 'Here_App_ID';
$config['secret'] = 'Here_Secret';
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
// Ottenere l'Application Token
$contents = "https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=".FACEBOOK_APP_ID."&client_secret=".FACEBOOK_SECRET;
$site_token = file_get_contents($contents);
$source_uid = "The_Source_ID"; // ID di chi pubblica (ID della pagina o del proprio profilo)
$target_uid = "Group_ID"; // ID della pagina o del proprio profilo
// Inviare il messaggio ( Stream Publish )
$url_facebook = "https://api.facebook.com/method/stream.publish?message=".$messaggio."&attachment={\"name\":\"".$titolo."\",\"href\":\"".$action_link."\",\"caption\":\"".$caption."\",\"description\":\"".$testo."\",\"media\":[{\"type\":\"image\",\"src\":\"".$image."\",\"href\":\"".$action_link."\"}]}&action_links=[{\"text\":\"".$link_name."\",\"href\":\"".$action_link."\"}]&target_id=".$target_uid."&uid=".$source_uid."&".$site_token."";
// echo $url_facebook."";
simplexml_load_file("".$url_facebook."");
}