Exemple #1
0
    echo "Facebook user is logged in and user ID set<br />";
    $fb_username = $facebook->api_client->users_getInfo($fb_user, 'name');
    $fb_username = $fb_username[0]['name'];
} catch (Exception $e) {
    echo "EXCEPTION: " . $e->message;
}
if (isset($_GET['sessionKey']) && isset($fb_user) && $fb_user > 0) {
    $session_key = $_GET['sessionKey'];
    echo "DEBUG:";
    echo "Session Key: " . $session_key . "<br />";
    $od = new OwnerDAO($db);
    $id = new InstanceDAO($db);
    $oid = new OwnerInstanceDAO($db);
    $ud = new UserDAO($db);
    $owner = $od->getByEmail($_SESSION['user']);
    $i = $id->getByUserId($fb_user);
    if (isset($i)) {
        echo "Instance exists<br />";
        $oi = $oid->get($owner->id, $i->id);
        if ($oi == null) {
            //Instance already exists, owner instance doesn't
            $oid->insert($owner->id, $i->id, $session_key);
            //Add owner instance with session key
            echo "Created owner instance.<br />";
        }
    } else {
        //Instance does not exist
        echo "Instance does not exist<br />";
        $id->insert($fb_user, $fb_username, 'facebook');
        echo "Created instance";
        $i = $id->getByUserId($fb_user);