|
Disclaimer:
These pages about different languages / apis / best practices were mostly jotted down quckily and rarely corrected afterwards. The languages / apis / best practices may have changed over time (e.g. the facebook api being a prime example), so what was documented as a good way to do something at the time might be outdated when you read it (some pages here are over 15 years old). Just as a reminder. Developer notes on doing different facebook integrations (connect, opengraph etc)Some notes on facebook development (e.g. connect, opengraph)LinksGraph APIphp-sdk Facebook slow things downOn a project of mine I use Facebook connect. In the header of the page I display the avatar of the user from facebook. This caused the web page to be very slow at times when facebook was having problems. So what I did was to load the facebook avatar in parallel, below is the code snippets i use:the html that should display the avatar: <img src="icon.php">icon.php: /* * redirect to the facebook image for the logged in user */ try{ require_once '/var/www.website.safe/include/util/error_handling.php'; require_once '/facebookcode/include/config.php'; session_start(); require_once ('/facebookcode/include/login.php'); require_once '/facebookcode/connect/websiteFacebook.php'; if(! loginIsUserLoggedin()){ $img = '/img/default.png'; }else{ if(isset($_SESSION['fb_iconurl'])){ $img=$_SESSION['fb_iconurl']; }else{ $img= websiteFacebookGetUserImage(); if(isset($img)){ $_SESSION['fb_iconurl']=$img; } } } header( "Location: $img" ); }catch(Exception $e){ require_once '/facebookcode/include/util/logger.php'; logger_LogMsg("problem in fbparallell: Exception=".$e); $img = '/img/default.png'; header( "Location: $img" ); } The websiteFacebookGetUserImage() does in essence this: $old_rest_call_param = array('method' => 'users_getInfo', 'uids' => $facebook->getUser(), 'fields' => 'pic_square_with_logo'); $user_details=$facebook->api($old_rest_call_param); if(! empty($user_details)){ return $user_details[0]['pic_square_with_logo']; }else{ return ""; } Alternative to fbml login button<a href="#" onclick="FB.Connect.requireSession(function (){window.myCallbackMethod();}); return false;" ><img id="fb_login_image" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_dark_large_short.gif" alt="Connect"/></a> Displaying friends with avatarsfunction facebookOpengraphGetUsers(){ global $configFacebookApiKey; global $configFacebookSecret; require_once "/facebook/connect/facebook.php"; $facebook = new Facebook($configFacebookApiKey, $configFacebookSecret); //get all friends that also uses this app $tmp = $facebook->api_client->friends_getAppUsers(); $user_details = $facebook->api_client->users_getInfo($tmp, 'last_name, first_name, pic_square_with_logo'); return $user_details; } More programming related pages |
|