BernaMariano
BernaMariano

Reputation: 866

PHP auto post on a group of Facebook

I have a site where people can make posts on it, and I need these posts to go straight to the feed of a group in Facebook. (I am the owner of the group)

Is it possible? What do I need? How should it work?

I found this https://github.com/facebook/php-sdk, but I don't if it is what I need, and couldn't figure out how does it work.

Upvotes: 1

Views: 8526

Answers (3)

Profesnel Legends
Profesnel Legends

Reputation: 1

 function Promote(){
           var lnk = 'http://www.wootube.woolei.com?v=<?php echo $_GET["id"] ?>';  

        FB.login(function(response)
        {
            if (response.authResponse)
            {
                 //Post To WooTube Group
                 FB.api('/271691796276524/feed', 'post', { 
                 message: lnk,
                 link: lnk, 

                 }, 
                 function(response) {
                   if (!response || response.error) {
                     //alert('You have to join the group first!');

                  } else {
                     //alert("Successfully Posted to WooTube Group!");

                   }
                 });

                 //Post to Wootube Page
                 FB.api('/173724382762792/feed', 'post', { 
                 message: lnk,
                 link: lnk

                 }, 
                 function(response) {
                   if (!response || response.error) {
                     //alert('You have to like http://www.facebook.com/WooTubes first!');

                  } else {
                     //alert("Successfully Posted to WooTube Page!");

                   }
                 });

            }
            else
            {
                alert('Not logged in');
            }
        }, { scope : 'publish_stream' });


      }

Upvotes: 0

Woo Lei
Woo Lei

Reputation: 31

i have a similar function in my application - wootube, i added a "Share To WooTube Page & Group" button using fb.api .

After the user click the link it will automatically post to wootube group and wootube page.

here is the screen shot if you want to see how it look like. https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash4/383568_191076937694203_922285357_n.jpg

 function Promote(){
           var lnk = 'http://www.wootube.woolei.com?v=<?php echo $_GET["id"] ?>';  

        FB.login(function(response)
        {
            if (response.authResponse)
            {
                 //Post To WooTube Group
                 FB.api('/271691796276524/feed', 'post', { 
                 message: lnk,
                 link: lnk, 

                 }, 
                 function(response) {
                   if (!response || response.error) {
                     //alert('You have to join the group first!');

                  } else {
                     //alert("Successfully Posted to WooTube Group!");

                   }
                 });

                 //Post to Wootube Page
                 FB.api('/173724382762792/feed', 'post', { 
                 message: lnk,
                 link: lnk

                 }, 
                 function(response) {
                   if (!response || response.error) {
                     //alert('You have to like http://www.facebook.com/WooTubes first!');

                  } else {
                     //alert("Successfully Posted to WooTube Page!");

                   }
                 });

            }
            else
            {
                alert('Not logged in');
            }
        }, { scope : 'publish_stream' });


      }

Upvotes: 0

cpilko
cpilko

Reputation: 11852

To do this you'll need to:

  • Create an app to connect your website to Facebook. Once the app is created, you need to get token and secret to authenticate your app with the Facebook servers.
  • Capture the comments on your site.
  • POST those comments to your Facebook group using the Graph API.

Additionally, to prevent spam, you may want to authenticate your users with Facebook before they comment.

If you're doing this in PHP, the PHP SDK saves you a lot of coding. To use it, your php environment must have cURL installed and enabled.

Upvotes: 1

Related Questions