1 / 17

Facebook API

Teppo Räisänen Teppo.raisanen@oamk.fi School of Business and Information Management. Facebook API. FBML and FBJS. API = application programming interface It is a way to utilize Facebook core features and user data. FBML and FBJS. FBML is similar to HTML FBJS is similar to JavaScript

marthaf
Download Presentation

Facebook API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Teppo Räisänen | Oulu University of Applied Sciences Teppo Räisänen Teppo.raisanen@oamk.fi School of Business and Information Management Facebook API

  2. 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. 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. 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. 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. Teppo Räisänen | Oulu University of Applied Sciences API • http://developers.facebook.com/docs/ • Facebook is constantly developing the API • The examples here use REST API • http://developers.facebook.com/docs/reference/rest/ • Graph API is the new version • http://developers.facebook.com/docs/reference/api/

  7. 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. 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. 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. Teppo Räisänen | Oulu University of Applied Sciences API-calls in PHP • You utilize the API-calls in PHP like this • Create a facebook-instance from Facebook class • $facebook->api_client->FUNCTION_CALL();

  11. 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. 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. 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. 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/fbml/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. 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: <fb:prompt-permission perms='status_update'> Permit the app to update your status? </fb:prompt-permission> You can use many permissions at the same time: <fb:prompt-permission perms=’publish stream, status_update'> Permit the app to publish to stream and update your profile? </fb:prompt-permission>

  16. Teppo Räisänen | Oulu University of Applied Sciences FQL • Facebook Query Language – 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. 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/

More Related