Download presentation
Presentation is loading. Please wait.
Published byAsher Chinnock Modified over 10 years ago
1
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences Facebook API Teppo Räisänen Teppo.raisanen@oamk.fi School of Business and Information Management
2
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences FBML and FBJS API = application programming interface It is a way to utilize Facebook core features and user data
3
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences FBML and FBJS FBML is similar to HTML FBJS is similar to JavaScript API-calls are close to PHP-function calls The reason for that is that we use Facebook’s PHP-API
4
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API -calls <?php require_once ”facebook.php”; $apikey = ”asdflgasdflkhasdfgasdlfg”; $secret = ”asdf8970adsf70as78asdf”; $facebook= new Facebook($apikey, $secret); $user=$facebook->require_login(); print $user; ?>
5
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API API-calls allow developers to utilize Facebook core features and data “get the user’s friends” “get/set user’s status” “Publish data to user’s profile” “Make a SQL-query to Facebook database” You don’t have to use them They do allow more complicated applications!
6
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API http://developers.facebook.com/docs/ http://developers.facebook.com/docs/ Facebook is constantly developing the API The examples here use REST API http://developers.facebook.com/docs/reference/rest/ http://developers.facebook.com/docs/reference/rest/ Graph API is the new version http://developers.facebook.com/docs/reference/api/
7
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences REST API Administrative methods Handles application and user data Examples admin.banUsers admin.getMetrics Login/Auth methods Logins and session handling Usually you don’t need to use this Example auth.expireSession
8
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences REST API Data retrieval methods Data handling Most often used part of the API Examples friends.get, status.get users.getInfo Publishing methods Publish data on profile/home page Important for viral growth! Examples stream.publish status.set
9
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences REST API Facebook Connect methods For using Facebook Connect Mobile methods Sending SMS Dashboard API methods Handles dashboard calls dashboard.addNews Events API methods Handles Facebookin events Events.create Custom Tags API methods Handles custom made tag calls
10
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API-calls in PHP You utilize the API-calls in PHP like this 1.Create a facebook-instance from Facebook class 2.$facebook->api_client->FUNCTION_CALL();
11
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API-calls from PHP $facebook = new Facebook($apikey, $secret); $facebook->api_client-> users_getInfo($user, “first_name”); Note, that users.getInfo is: users_getInfo Usually API-calls return an array
12
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API-calls from PHP $user_details = $facebook->api_client-> users_getInfo($user, 'last_name, first_name’); $firstname=$user_details[0]['first_name']; $lastname=$user_details[0]['last_name']; print “Your name is $firstname $lastname”;
13
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API-call examples Get all $user’s friends: $friends= $facebook->api_client->friends_get($user); Get all $user’s photos: $photos = $facebook->api_client->photos_get($user,'',''); Set status: $facebook->api_client->users_setStatus("facebook coding");
14
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API-calls in PHP Some API-calls require special permissions status update Retrieving data does not usually need permission http://developers.facebook.com/docs/reference/f bml/prompt-permission/ http://developers.facebook.com/docs/reference/f bml/prompt-permission/ publish_stream, read_stream email, read_mailbox offline_access create_event, rsvp_event sms status_update photo_upload, video_upload create_note share_item
15
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences API-calls in PHP You can chech the permission with users.hasAppPermission $facebook->api_client- >users_hasAppPermission('status_update'); Returns 1, is there is permission to status update. 0 if not You can ask permission with fb:prompt-permission FBML- tag: Permit the app to update your status? You can use many permissions at the same time: Permit the app to publish to stream and update your profile?
16
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences FQL Facebook Query Language – FQL http://developers.facebook.com/docs/reference/fql http://developers.facebook.com/docs/reference/fql Allows SQL-querys to Facebook database $sql = “SELECT name, pic FROM user WHERE uid= 720633037”; $results = $facebook->api_client->fql_query($sql);
17
OULU ADVANCED RESEARCH ON SOFTWARE AND INFORMATION SYSTEMS Teppo Räisänen | Oulu University of Applied Sciences Facebook Tools Facebook has few tools that can be used to test e.g. FBJS http://developers.facebook.com/tools/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.