Facebook access_token Storing in DB

Discussion in 'PHP' started by Elfiana, Mar 11, 2013.

  1. #1
    Hey trying to store access tokens in my DB i got some example script here trying to make it work but no success.Hope someone can help me to make this
    Here code im trying to get working
    Does not insert anything to DB...



     <?php
    error_reporting( E_ALL );
      ini_set('log_errors', true);
      ini_set('error_log', 'errors.txt');
    # We require the library
    require("src/facebook.php");
    require("db.php");
    require("config.php");
    # Creating the facebook object
    $facebook = new Facebook(array(
    'appId' => $app_id,
    'secret' => $app_secret,
    'cookie' => true
    ));
    # Let's see if we have an active session
    $session = $facebook->getUser();
    if(!empty($session))
    {
    try
    {
    $fbid = $session['uid'];
    $access_token=$session['access_token'];
    // Updating Facebook values into Users table
    mysql_query("UPDATE users SET fbid='".$fbid."', access_token='".$access_token."' ");
    echo mysql_error();
    header("Location: http://domain.com/test/home.php");
    }
    catch (Exception $e){}
    }
    else
    {
    header("Location: http://domain.com/test/home.php");
    }
    ?>
    Code (markup):
     
    Elfiana, Mar 11, 2013 IP