August 19, 2014 2:11 pm

How to Post Into Facebook Group with PHP using Graph API

Hey guyz I received many requests from my readers to write tutorial on facebook Group status update so I am going to show you that how you can do update your joined groups. You can joined many groups and update your status on groups to promote your websites or your products on all groups and this is an easy way to promotion.

post into a Facebook Page with PHP using Graph API

How to integrate:

To create Facebook application follow instruction on my previous post How to Login with Facebook Graph API in PHP

We need permissions publish_actions, user_groups to run this code on your website. You need to send request to facebook to review your application permission and allow your app for these permissions Read more.

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

src

– base_facebook.php // Class Get user Information.

– facebook.php // Class Get user Information.

– config.php // Configuration file.

images

index.php // Main index file.

PHP Code

Edit config.php

First of all we get current user’s joined groups list and display in drop down.

Now we have all joined groups list in $dropdown variable.

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

Publish Link with Image:

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

Post on facebook group

Publish text status only only:

Above code share only text status on your selected group.

Post text status on facebook group

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

Above code first of all authenticate you permission from facebook and then show a form with a drop down and a text box to select group and status to update.

In my script you can post on one group at 1 time but if you want to post on all groups in one click you can modify script and do it easily.

You can can make change and create a auto facebook group posting application.

That’s all for this tutorial hope you guyz like this tutorial please feel free to comment below.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:
  • URAGANU .

    Thank you for this tutorial.
    Until now I succeeded to extract the feed from a Facebook Group and include it in a Android App using appyet.com. Now all the feeds display on the phone and I don’t have to keep facebook app open.
    When they will upgrade their templates and allow php scripts to run I will implement this into same application to have a fully operational Facebook Group Application :D.

    Thank you one more time, this resource is priceless.

    • Lilesh Jadav

      but facebook feed needs login into facebook acc. and how can you login facebook into appyet app ??

  • tag

    I cannot download the source code. I’m already subscribed to the mailing list .But can’t download can you please email me a sourcecode.

  • ajay dubey

    i need you help when i download code then its work fine only 1 issue is their can u suggest me how i can fetch group account to user login

  • ajay dubey

    now its working with single user onlt its get single user group

  • ajay dubey

    hello

  • ajay dubey

    anybody here

  • ajay dubey

    anybody can help me

  • Đặng Đình Sơn

    code not working it’s not load group

    • huzoorbux

      Please send me errors.

      • Đặng Đình Sơn

        thanks you so much , it’s works

  • Đặng Đình Sơn

    Please help me for a trouble ?
    It’s not show scope when user access apps.
    sorry for my English

  • Đảo Hoang

    hello. i can’t download code. please help me

    • huzoorbux

      What is the problem you are facing”

  • ashishrevar

    Hello there,
    I need to publish link on all my groups. I set sleep(10) after every post. I am getting below listed error.
    What to do?
    Fatal error: Uncaught FacebookApiException: Permissions error thrown in /home/storyreads/storyreads.com/fb/base_facebook.php on line 1325

  • Trần Tiến Lực

    Hello.
    I did as in your tutorial but it does not work. Could you please help me. This is my error

    “The parameter app_id is required”

    I think that the problem is my facebook app, but I can not fix it. Please help me Thank you!

  • Bert

    Hello Dont show my groups

  • sun vichea

    can you tell me about auto post in all group ?

  • Sr plz help me. not show group name plz check this http://www.facebeokcomfblol.hostingsiteforfree.com/fbpost/index.php

    • huzoorbux

      Please send specific errors so i can help you try to debug.

      • i add this items in app plz tell me about this.sorry for english mistak.

  • Sr agr ap kahty hu tu username and password b dy dyta hu par plz sr mari help karo

  • sunny

    The redirect_uri URL must be absolute im having these error

    • huzoorbux

      What url you are sending?

  • Sr this is error plz solve my problem plz sr.first time join this site plz help me

  • Sr kun kun sy items select karny is group posting ky lye.

  • Trần Lý Như

    demo is not working. i can’t choose Group

  • Mêồʬ ḿėẘ

    The redirect_uri URL must be absolute im having these error

  • arvind

    Please Help me in this.

  • Marcello Patto

    I got the error “The parameter app_id is required”. I have the app_id nad secret number as well, but, there´s something wrong… have you testing the script latelly? Have you an update or something?
    Thks a lot from Brazil!

  • Marcello Patto

    I got the error “The parameter app_id is required”. I have the app_id nad secret number as well, but, there´s something wrong… have you testing the script latelly? Have you an update or something?
    Thks a lot from Brazil!