banner 


A PHP Class For Facebook Application Developer

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!!!!

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
tabs-top  banner ad


15 Responses to “A PHP Class For Facebook Application Developer”

  1. pete UNITED KINGDOM says:

    I like this class, how do you adapt it as a buddpress plugin?

    buddypress site.

    http://www.buddypress.org

  2. shree NEPAL says:

    hi
    i know about this facebook class but can you explain more how to use this class in my application

  3. Billy UNITED KINGDOM says:

    Hey,

    wow this class sounds amazing. Do you have any more info on how to implement it?

    Billy?

  4. ehsan PAKISTAN says:

    hi

    can we send email to facebook users on facebook via facebook connect

    thanks

  5. [...] tratta di Facebook Toolbox, che incorpora in semplici metodi tutte le chiamate e le varie operazioni che possono tornarci [...]

  6. ehsan PAKISTAN says:

    hi

    Can u help to send invitation to facebook user like multi-selector invitation

  7. admin BANGLADESH says:

    @ehsan
    thanks to give time here.
    I am writting another one post
    about facebook application.
    so please stay with me.
    thanks
    raju

  8. ehsan PAKISTAN says:

    hi

    i mean when we like to send invitation to more then one friends in facebook we use multiselect option , now i like to send invitation like that but i want to send invitaion by using my own database , its possible to that with facebook or not ,

    if yes then how

    thanks

  9. Ayan Debnath INDIA says:

    I am facing one small problem/error -

    “Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘Session key invalid or no longer valid: ‘ in /home/gigahert/public_html/test/facebook/client/facebookapi_php5_restlib.php:2977 Stack trace: #0 /home/gigahert/public_html/test/facebook/client/facebookapi_php5_restlib.php(946): FacebookRestClient->call_method(’facebook.fql.qu…’, Array) #1 /home/gigahert/public_html/test/facebook/FBToolbox.class.php(126): FacebookRestClient->fql_query(’SELECT uid FROM…’) #2 /home/gigahert/public_html/test/facebook/FBToolbox.class.php(227): FbToolbox->getFriendList(’1015601512′, true) #3 /home/gigahert/public_html/test/facebook/1.php(52): FbToolbox->publishNewsFeed(’1015601512′, ‘115329175943′) #4 {main} thrown in /home/gigahert/public_html/test/facebook/client/facebookapi_php5_restlib.php on line 2977″

    Can you pls suggest me to solve it ?

  10. Jayanthi INDIA says:

    Use try catch block for your script as like,

    try{
    if(count($facebook->api_client->friends_get())>0){

    — your script here—

    }catch (Exception $ex) {
    $facebook->set_user(null,null);
    }

    I hope that the above script will help you.

  11. [...] A PHP Class For Facebook Application Developer [...]

  12. [...] Facebook Application Developer [...]

Leave a Reply