Graph api

17
Graph API

description

 

Transcript of Graph api

Page 1: Graph api

Graph API

Page 2: Graph api

SDKs & Tools

Page 3: Graph api

Introduction

SDKs lets you access Graph API and other JavaScript SDK (Graph API, dialogs) PHP SDK (Graph API, Login) iOS SDK (SSO, Graph API, dialogs) Android SDK (SSO, Graph API, dialogs) other (ex: c#)

Tools guides and tutorials debuggers (ex: Graph API Explorer)

https://developers.facebook.com/docs/sdks/

Page 4: Graph api

JavaScript SDK

Access Facebook server API calls from the client Graph API REST API Dialogs

Render XFBML social plugins Supports OAuth 2.0 App ID is needed to initialize the SDK

Page 5: Graph api

Initialization <div id="fb-root"></div> <script src="//connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId : '178747652203562', status : true, cookie : true, xfbml : true, oauth : true }); </script>

Page 6: Graph api

Platform dialogs - FB.ui() Integrate Facebook UI flow into the

application Feed Dialog Add a friend Authorize the application Buy credits Send application request Share a link

Page 7: Graph api

Feed dialog FB.ui( { method: 'feed', name: 'Developer Community', link: 'https://www.facebook.com/event.php?eid=206539312741159', picture: 'http://blog.mist.sk/wp-content/uploads/2011/10/FacebookDevSK-thumb.jpg', caption: 'Facebook Developer Community', description: 'The first Facebook developer community meeting in Bratislava' }, function(response) { if (response && response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } );

Page 8: Graph api

Feed dialog FB.ui( { method: 'feed', name: 'Developer Community', link: 'https://www.facebook.com/event.php?eid=206539312741159', picture: 'http://blog.mist.sk/wp-content/uploads/2011/10/FacebookDevSK-thumb.jpg', caption: 'Facebook Developer Community', description: 'The first Facebook developer community meeting in Bratislava' }, function(response) { if (response && response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } );

Page 9: Graph api

Feed dialog FB.ui( { method: 'feed', name: 'Developer Community', link: 'https://www.facebook.com/event.php?eid=206539312741159', picture: 'http://blog.mist.sk/wp-content/uploads/2011/10/FacebookDevSK-thumb.jpg', caption: 'Facebook Developer Community', description: 'The first Facebook developer community meeting in Bratislava' }, function(response) { if (response && response.post_id) { alert('Post was published.'); } else { alert('Post was not published.'); } } );

Page 10: Graph api

Application request FB.ui( { method: 'apprequests', message: 'Check the Bratislava Facebook Community meeting demo app' }, function(response) { // handle callback console.log(response); } );

Page 11: Graph api

Application request FB.ui( { method: 'apprequests', message: 'Check the Bratislava Facebook Community meeting demo app' }, function(response) { // handle callback console.log(response); } );

Page 12: Graph api

Application request FB.ui( { method: 'apprequests', message: 'Check the Bratislava Facebook Community meeting demo app' }, function(response) { // handle callback console.log(response); } );

Page 13: Graph api

User Authentication

Register to the website using Facebook or get the permissions for the app FB.login() FB.logout() FB.getLoginStatus() FB.getAuthResponse()

Advantages sharing logged in user state registration flow on the website isn't needed get access to the user's social graph

Page 14: Graph api

Login user FB.login( function(response) { if (response.authResponse) { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); }); } else { console.log('User cancelled login or did not fully authorize.'); } }, {scope: 'email'});

Page 15: Graph api

Login user FB.login( function(response) { if (response.authResponse) { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); }); } else { console.log('User cancelled login or did not fully authorize.'); } }, {scope: 'email'});

Page 17: Graph api

Milan STESKAL

@milansteskal @facebookDevSk facebook.com/groups/188066214578728/