If you want to connect your Joomla-powered Website to social media sites like Facebook you don't need to reinvent the wheel and write those lines of API integration yourself. So how do you achieve putting that become a fan or join this group button onto your Joomla Website ?
1.) First you would need to get familiar with Facebook's Developer Pages.
Enter www.facebook.com/developers and create a new application. There will be an Facebook API Key generated.
Then, click on Connect in the menue on the left and point your app to your joomla website and site domain.
2.) Now we need a Facebook plugin for Joomla, I found Facebook Fanbox Free to be a good choice. Don't confuse the name with Facebook's internal Fanbox.
Now download the zipfile and upload it via the Joomla Backend Administration Panel by clicking on Components -> Install.
3.) After the successfull installation go to Extensions -> Modules and filter for face. Then click the module to edit it. Here you can enter a lot of parameters, but the most important change you have to make would be to enter the API key and the groupID.
So switch to Facebook Connect and copy the API key and look for the GroupID in the URL of your Facebook group in the Browser Adress Bar. Now enter that ID into Joomla's Fanbox Free Module where it says Page ID.
Then activate the module and tap yourself on the shoulder. Your website visitors now can directly join your Facebook group. In my opinion this is what the Web 2.0 is all about; easy-to-implement API's meshing up various social media services.