Posted inProgramming / Mysql / Mysqli / php

How to Post Into Facebook Group with PHP using Graph API

How to Post Into Facebook Group with PHP using Graph API

In this Post We Will Explain About is How to Post Into Facebook Group with PHP using Graph API With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Graph API Reference Group /group Example

In this post we will show you Best way to implement Post on a Facebook Group using 2.0+ API, PHP SDK, hear for How to Post Into Facebook Group with PHP using Graph API with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Post to Facebook Group Wall PHP API Example

To Make Facebook web-application follow some step by step instruction on my simple previous data post How to Login with Facebook Graph API in PHP

We need simple permissions data like as a publish_actions and user_groups to simple run this source code on your new website. We need to simple send request to data facebook to data review your web application data permission and simple allow your web-app for these data permissions permission Read or more/p>

Script contains two folders called src and images with PHP files.

src
– base_facebook.php //Pakainfo.com Class Get user Information.
– facebook.php //Pakainfo.com Class Get user Information.
– config.php //Pakainfo.com Configuration file.
images
index.php //Pakainfo.com Main index file.
PHP Code

Edit config.php


First of all simple we get current facebook user’s joined all groups simple list and see in drop down box.

data);$i++)
    {
        $dropdown .= "";
    }
?>

And then we have all simple joined groups list in $dropdown variable.

Posting on any facebook Group is simply like we make post on facebook page in our data previous Article How to simple post into a data Facebook Page with simple PHP using Live Graph API below is the source code for posting.

Publish Link with Image:

$publish = $facebook->api('/'.$live_group_id.'/feed', 'post',
            array('access_token' => $_SESSION['token'],
            'message'=> 'Live Data Testing',
            'from' => $config['App_ID'],
            'to' => $live_group_id,
            'caption' => 'PHP live24u',
            'name' => 'PHP live24u',
            'link' => 'https://www.Pakainfo.com/',
            'picture' => 'https://www.Pakainfo.com/wp-Data_content/themes/live24u_v2/img/logo.png',
            'description' => 'Live Data Testing with Pakainfo.com Demo'
            ));

Above code post on facebook group a link with image see attached image.

Publish text status only only:

$publish = $facebook->api('/'.$live_group_id.'/feed', 'post',
        array('access_token' => $_SESSION['token'],'message'=>$_POST['status'] .'   via Pakainfo.com Demo',
        'from' => $config['App_ID']
        ));

Above simple source code share data only text some status on your id means selected group.

Here is my simple complete source code data to get user simple user authentication and data post status:

 $config['App_ID'],
  'secret' => $config['App_Secret'],
  'cookie' => true
));

if(isset($_POST['status']))
{
    $live_group_id = $_POST['group'];
    
    $publish = $facebook->api('/'.$live_group_id.'/feed', 'post',
            array('access_token' => $_SESSION['token'],
            'message'=> 'Live Data Testing',
            'from' => $config['App_ID'],
            'to' => $live_group_id,
            'caption' => 'PHP live24u',
            'name' => 'PHP live24u',
            'link' => 'https://www.Pakainfo.com/',
            'picture' => 'https://www.Pakainfo.com/wp-Data_content/themes/live24u_v2/img/logo.png',
            'description' => 'Live Data Testing with Pakainfo.com Demo'
            ));
        $publish = $facebook->api('/'.$live_group_id.'/feed', 'post',
        array('access_token' => $_SESSION['token'],'message'=>$_POST['status'] .'   via Pakainfo.com Demo',
        'from' => $config['App_ID']
        ));
        $message = 'here success Status updated.
'; $graph_url_groups = "https://graph.facebook.com/v2.1/me/groups?access_token=".$_SESSION['token']; $groups = json_decode(live_dynemic_get_data_curl($graph_url_groups)); $dropdown = ""; for($i=0;$idata);$i++) { $dropdown .= ""; } $Data_content = ' '.$message.'
Select any Group on which We want to post status:


'; } elseif(isset($_GET['fbTrue'])) { $token_url = "https://graph.facebook.com/v2.1/oauth/access_token?" . "client_id=".$config['App_ID']."&redirect_uri=" . urlencode($config['callback_url']) . "&client_secret=".$config['App_Secret']."&code=" . $_GET['code']; $response = live_dynemic_get_data_curl($token_url); // get access token from url $live_param = null; parse_str($response, $live_param); $graph_url = "https://graph.facebook.com/v2.1/me?access_token=" . $live_param['access_token']; $_SESSION['token'] = $live_param['access_token']; $user = json_decode(live_dynemic_get_data_curl($graph_url)); // Get user information from given url $graph_url_groups = "https://graph.facebook.com/v2.1/me/groups?access_token=".$_SESSION['token']; $groups = json_decode(live_dynemic_get_data_curl($graph_url_groups)); // simple get all data groups information data from above url. $dropdown = ""; for($i=0;$idata);$i++) { $dropdown .= ""; } $Data_content = ' '.$message.' Select any live Group on which We want to simple post status:


'; } else { $Data_content = 'Sign in with Facebook'; } echo $Data_content; function live_dynemic_get_data_curl($url) { $my_ch = curl_init(); curl_setopt($my_ch, CURLOPT_HEADER, 0); curl_setopt($my_ch, CURLOPT_RETURNTRANSFER, 1); //simple Set curl data to return the simple data instead of all data printing it to the browser. curl_setopt($my_ch, CURLOPT_URL, $url); $data = curl_exec($my_ch); curl_close($my_ch); return $data; } ?>

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is How to Post Into Facebook Group with PHP using Graph API And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype