Pages

Showing posts with label facebook. Show all posts
Showing posts with label facebook. Show all posts

Wednesday, May 18, 2011

Get facebook friends list in an array

Here is the solution for getting facebook friends list in an array usinbg PHP

First of all you need to download latest facebook php sdk from https://github.com/facebook/php-sdk/downloads
 Then include facebook.php from the sdk directory to your php page.

 After that use below code to generate friends list in a array
 --------------------------------------------------------------------------------------------------------
$facebook = new Facebook(array(
  'appId'  => 'APP-ID',
  'secret' => 'APP-SECRET-KEY',
  'cookie' => true,
));

$friends = $facebook->api('/'. FACEBOOK-USER-ID .'/friends');
                $friendsList = array();
                foreach ($friends as $key=>$value)
                {
                   foreach ($value as $fkey=>$fvalue) {

                       $friendsList[] = $fvalue[id];
                   }

                }


print_r($friendsList);
 --------------------------------------------------------------------------------------------------------

Remove scroll bars from facebook iframe application

Step 1: Make "IFrame Size" to "Auto-resize" on the application settings page.

Step 2: Insert below code just before closing the head tag ( </head> ) on the child page.

<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setSize();
}
// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() {
FB.Canvas.setSize();
}
</script>


Step 3: Insert the below code just before closing body tag ( </body> ).


<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'YOUR-APP-ID-HERE',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>

** Please make sure to put your appid correctly.