A PHP Class For Facebook Application Developer
Posted: March 20th, 2009 | Author: admin | Filed under: facebook, php | Tags: application, class, developer, facebook, facebook application, news feed, profile | 15 Comments »You know facebook is a great social application for million of users. And to develop a application for this site is also very popular. So I have planned to write a class where facebook application developer can do most of the basic things for their application using this class.Specially thanks to emran bhai and anis to review my class.The basic feature of this class
- Get Facebook Users profile information
- Get Friend list of a facebook user
- Send Notification to Facebook user
- Send Email Notification to Facebook user
- Set Your Application at Facebook user profile page
- Publish News feed to Facebook user
You can do above all the things to use this Class.

Download
You can download it from here. The zip file contains this class along with an example. You can also find full documentation here.
You can also download it from phpclasses.org
How to use it
1: // Include our files
2: include_once ('FBToolbox.class.php');
3:
4: // Prepare the object
5: $fbToolboxObj = new FBToolbox('YOUR_API_KEY', 'YOUR_SECRET_KEY');
6:
7:
8: // Get user information
9: $userInfo = $fbToolboxObj->getUserInfo('FB USER ID');
10: //print_r($userInfo);
11: echo $userInfo[0]['current_location']['city'];
12:
13: // Get friend list here
14: $friendList = $fbToolboxObj->getFriendList('FB USER ID',false,0,20);
15: //print_r($friendList);
16:
17: // Send notification
18: $fbToolboxObj->sendNotification(array('FB USER ID'),'test api class','app_to_user');
19:
20: // Send email notification (CAUTION: your application must have permission from user)
21:
22: $fbToolboxObj->sendEmail('FB USER ID','test api class','test api class');
23:
24: // Publish news feed
25:
26:
27: $one_line_story_templates[] = '{*actor*} has developed a php wrapper
28: class for facebook application developer.';
29: //You have to run this function only one times to get template bundle id
30: $templateBundleId = $fbToolboxObj->getTemplateBundleId($one_line_story_templates);
31:
32: $fbToolboxObj->publishNewsFeed('FB USER ID',$templateBundleId);
33:
34: // Add your application to your profile
35: $fbToolboxObj->addToProfile('FB USER ID',"Wider FbMl","narrow fbml");
36: ?>
37:
38: <!-- you have to print this line to add application to user profile
39: if user click on addtoprofile link then above function will work -->
40: <div class="section_button"><fb:add-section-button section="profile"/></div>
41:
So devs this is all about my php class. In my next post I will show you how to develop a facebook application with new platform in details using this class. Enjoy!!!!