13
Facebook authorization API Irina Vedkal Developer Berlingske Media IT

Facebook authorization API (Irina Vedkal)

  • Upload
    ciklum

  • View
    2.091

  • Download
    3

Embed Size (px)

DESCRIPTION

This presentation was shared by Irina Vedkal during Ciklum PHP Saturday (18/02/2012) in Odessa.

Citation preview

Page 1: Facebook authorization API (Irina Vedkal)

Facebook authorization API

 Irina VedkalDeveloper

Berlingske Media IT

Page 2: Facebook authorization API (Irina Vedkal)

Agenda

1. Intoduction;2. Facebook sdk:- front-end implementation;- back-end implementation;- methods to use;- issues and fixes;- facebook graph;

Page 3: Facebook authorization API (Irina Vedkal)

Introduction

Facebook allow: • Social Plugins• Authentication• Analytics

Page 4: Facebook authorization API (Irina Vedkal)

Front-end implementation<html>     <head><title>My Facebook Login Page</title></head>     <body>         <div id="fb-root"></div>             <script> window.fbAsyncInit = function() {                 FB.init({ appId: 'YOUR_APP_ID', status: true, cookie: true, xfbml: true, oauth: true, }); };                 (function(d){                     var js, id = 'facebook-jssdk';                     if (d.getElementById(id)) {return;}                     js = d.createElement('script');                     js.id = id; js.async = true;                     js.src = "//connect.facebook.net/en_US/all.js";                    d.getElementsByTagName('head')[0].appendChild(js);                 }(document));             </script>             <div class="fb-login-button">Login with Facebook</div>       </body> </html>

Page 5: Facebook authorization API (Irina Vedkal)

View on site

  

Page 6: Facebook authorization API (Irina Vedkal)
Page 7: Facebook authorization API (Irina Vedkal)

Back-end implementation

require_once("sdk/facebook.php"); $config = array(); $config[‘appId’] = 'YOUR_APP_ID'; $config[‘secret’] = 'YOUR_APP_SECRET'; $facebook = new Facebook($config);   Methods:• Facebook::getUser(), • Facebook::getLoginUrl(),• Facebook::getLogoutUrl()

Page 8: Facebook authorization API (Irina Vedkal)

Get login url  public function getLoginUrl($params=array()) {    $currentUrl = $this->getCurrentUrl();

    return $this->getUrl('www', 'login.php',      array_merge(array(        'api_key'               => $this->getAppId(),        'cancel_url'           => $currentUrl,        'display'                => 'page',        'fbconnect'            => 1,        'next'                     => $currentUrl,        'return_session'    => 1,        'session_version'  => 3,        'v'                          => '1.0',      ), $params)    );  }

Page 9: Facebook authorization API (Irina Vedkal)

Not set permissions access

        $params = array(             'legacy_return'   => 1,        'method'            => 'permissions.request',        'scope'              => 'email',     );

Page 10: Facebook authorization API (Irina Vedkal)

Get user - Facebook graph API

https://graph.facebook.com/ID  {     "id": "100002655856449",     "name": "Irina Vedkal",     "first_name": "Irina",     "last_name": "Vedkal",     "link": "http://www.facebook.com/...56449",     "gender": "female",     "locale": "en_US" }   https://graph.facebook.com/100002655856449 

Page 11: Facebook authorization API (Irina Vedkal)

Custom fields

https://graph.facebook.com/100002655856449?fields=id,name,picture

{ "id": "100002655856449", "name": "Irina Vedkal", "picture": "http://profile.ak.....jpg" }

Page 12: Facebook authorization API (Irina Vedkal)

Get additional data

http://graph.facebook.com/100002655856449/picture http://graph.facebook.com/100002655856449/picture?type=large  Methods: 

•  /picture;•  /events;•  /albums; •  /photos;

  

Page 13: Facebook authorization API (Irina Vedkal)

That was it

Time to ask questions )))