<p><a href="http://api.facebook.com/login.php?api_key=<?php echo $facebook_api_key; ?> " target="_blank">log in to facebook</a></p> <form method="GET"><p>then paste the token from the url here: <input type="text" name="auth_token" size="20"><input type="submit" value="finish login"></p></form> <? } } if ($session_key) { echo "<p>logged in as $uid, with sess key $session_key</p>"; echo "<p>Trying to getInfo</p>"; try { $r = $client->users_getInfo(array($uid), array("about_me", "affiliations", "birthday", "books", "clubs", "current_location", "first_name", "gender", "hometown_location", "hs_info", "interests", "last_name", "meeting_for", "meeting_sex", "movies", "music", "name", "political", "pic", "relationship_status", 'quote', "school_info", "tv", "work_history")); } catch (Exception $e) { echo "<script>location.href='?newsession_req=1'</script>"; exit; } echo "<div clear='all'><p>user info:</p><pre>".htmlspecialchars(var_export($r, TRUE))."\n" .htmlspecialchars($client->last_xml) ."</pre>"; } ?>
} $client = new FacebookRestClient($config['rest_server_addr'], $config['api_key'], $config['secret'], $session_key, false); if (!$session_key) { $expires = time() + 3600; $session_info = $client->auth_getSession($auth_token); $client->session_key = $session_info['session_key']; $uid = $session_info['uid']; /* You should not blindly trust cookies to provide valid authentication * information since they are transmitted in the clear and can be easily * modified (especially not for the user id). We encourage you to use your * own more advanced session management system, we merely do this as an * example. */ setcookie('session_key', $session_info['session_key'], $expires); setcookie('uid', $uid, $expires); } $my_profile = $client->users_getInfo(array($uid), $profile_field_array); $my_name = $my_profile[$uid]['name']; $friends_array = array_slice($client->friends_get(), 0, 5); $coworkers_array = $client->friends_getTyped('WORKED'); $albums = $client->photos_getAlbums($uid); $album_photos = $client->photos_getFromAlbum($albums[0]['aid'], $uid); $friend_profiles = $client->users_getInfo($friends_array, $profile_field_array); $events = $client->events_getInWindow(time(), time() + 86400 * 30); $photos = $client->photos_getOfUser($uid, 5); $messages = $client->messages_getCount(); $wall_count = $client->wall_getCount(); $are_friends = $client->friends_areFriends($friends_array[0], $friends_array[1]); print "<html><head><title>Example PHP5 REST Client</title></head><body>"; print '<a href="sample_client.php?logout=1">logout</a>'; print "<h2>{$my_name}'s info </h2>"; print '<P>Total messages: ' . $messages['total'] . ', unread: ' . $messages['unread'];
/** int fb_sig_user The uid of the person who is uninstalling your application (e.g. 609143784) string fb_sig_session_key The session_key originally given to your application for the user who is uninstalling the application. This parameter did not appear in the latest requests. string fb_sig_api_key The api_key of your application that is being uninstalled. int fb_sig_added n/a string fb_sig */ private function getContext(FacebookRestClient $client, RingsideSocialSession $network_session) { $api_key = $client->api_key; $session_key = $client->session_key; $uid = $client->users_getLoggedInUser(); $social_session_key = $network_session->getSessionKey(); $names = $client->users_getInfo($uid, "first_name"); $name = $names[0]; $user_name = trim($name['first_name']); return "fb_sig_user={$uid}&user_name={$user_name}&fb_sig_api_key={$api_key}&fb_sig_session_key={$session_key}&social_session_key={$social_session_key}"; }