The snippet bellow show how to use Original Facebook and Twitter social apis with HybridAuth:

  1. <?php
  2. $config = dirname(__FILE__) . '/library/hybridauth.php';
  3. require_once( "library/Hybrid/Auth.php" );
  4.  
  5. try{
  6. $hybridauth = new Hybrid_Auth( $config );
  7.  
  8. # try to authenticate with some providers
  9.  
  10. $facebook = $hybridauth->authenticate( "Facebook" );
  11.  
  12. $twitter = $hybridauth->authenticate( "Twitter" );
  13.  
  14. # now try to play with theses social apis
  15.  
  16. # Facebook: https://developers.facebook.com/docs/reference/api/
  17. // ask facebook for friends list
  18. $response = $facebook->api()->api('/me/friends');
  19.  
  20. // Post to the user wall
  21. $response = $facebook->api()->api("/me/feed", "post", array(
  22. message => "Hi there",
  23. picture => "http://www.mywebsite.com/path/to/an/image.jpg",
  24. link => "http://www.mywebsite.com/path/to/a/page/",
  25. name => "My page name",
  26. caption => "And caption"
  27. ));
  28.  
  29. # Twitter: https://dev.twitter.com/docs/api
  30. // Returns the current count of friends, followers, updates (statuses) ...
  31. $response = $twitter->api()->get( 'account/totals.json' );
  32.  
  33. // You get the point
  34. }
  35. catch( Exception $e ){
  36. echo "Ooophs, we got an error: " . $e->getMessage();
  37. }