locked
Facebook authentication is incredibly slow RRS feed

  • Question

  • Hey Guys,

    we are trying to use azure websites as an backend for our app. The app is using Facebook OAuth for user authentication.

    We are using the official PHP-SDK provided by facebook

    Here is our code:

    $facebook = new Facebook($config);
    
    $facebook->setAccessToken($params["fbtoken"]);
    			
    $fbUser = $facebook->api("/me");
    
    logMsg("Handle registration");
    $facebook->setAccessToken($params["fbtoken"]);
    $fbUser = $facebook->api("/me");
    
    $sql="SELECT * FROM bq_users WHERE fb_id='".mysql_real_escape_string($fbUser["id"])."'";
    logMsg($sql);
    ...

    When we run the script on our local maschines or on our webserver, the "/me"-requests takes about 200ms.

    Log:

    {"time":1385555609.7717,"offset":0.0001,"msg":"Handle registration"}
    {"time":1385555610.2586,"offset":0.4869,"msg":"SELECT * FROM X WHERE fb_id='XXX'"}

    On Azure we experience way more than 3 seconds. 

    Log:

    {"time":1385555673.3911,"offset":0.0001,"msg":"Handle registration"}
    {"time":1385555676.8602,"offset":3.4691,"msg":"SELECT * FROM bq_users WHERE fb_id='XX'"}

    Any ideas how to fix that


    Wednesday, November 27, 2013 12:36 PM

Answers

  • I have no idea, why this takes so long, but we solved the issue by directly using the rest api without the sdk:

    $fbUser=json_decode(file_get_contents("https://graph.facebook.com/me?type=post&access_token=".$params["fbtoken"]),true);


    • Marked as answer by Tobias Sell Thursday, November 28, 2013 9:08 AM
    Thursday, November 28, 2013 9:08 AM

All replies

  • I have no idea, why this takes so long, but we solved the issue by directly using the rest api without the sdk:

    $fbUser=json_decode(file_get_contents("https://graph.facebook.com/me?type=post&access_token=".$params["fbtoken"]),true);


    • Marked as answer by Tobias Sell Thursday, November 28, 2013 9:08 AM
    Thursday, November 28, 2013 9:08 AM
  • Cool. Thanks for the sharing.
    Thursday, November 28, 2013 11:09 AM