www.webdeveloper.com
Results 1 to 2 of 2

Thread: Fatal error: Call to undefined function GetUserIdForUserToken()

  1. #1
    Join Date
    Mar 2012
    Posts
    1

    Fatal error: Call to undefined function GetUserIdForUserToken()

    This is for a social login script from oneall.com I am at a loss.

    [CODE][<?php

    //Check if we have received a connection_token
    if ( ! empty ($_POST['connection_token']))
    {
    //Get connection_token
    $token = $_POST['connection_token'];

    //Your Site Settings
    $site_subdomain = '';
    $site_public_key = '';
    $site_private_key = '';

    //API Access domain
    $site_domain = $site_subdomain.'.api.oneall.com';

    //Connection Resource
    //http://docs.oneall.com/api/resources/connections/read-connection-details/
    $resource_uri = 'https://'.$site_domain.'/connections/'.$token .'.json';

    //Setup connection
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $resource_uri);
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_USERPWD, $site_public_key . ":" . $site_private_key);
    curl_setopt($curl, CURLOPT_TIMEOUT, 15);
    curl_setopt($curl, CURLOPT_VERBOSE, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($curl, CURLOPT_FAILONERROR, 0);

    //Send request
    $result_json = curl_exec($curl);

    //Error
    if ($result_json === false)
    {
    //You may want to implement your custom error handling here
    echo 'Curl error: ' . curl_error($curl). '<br />';
    echo 'Curl info: ' . curl_getinfo($curl). '<br />';
    curl_close($curl);
    }
    //Success
    else
    {
    //Close connection
    curl_close($curl);

    //Decode
    $json = json_decode ($result_json);

    //Extract data
    $data = $json->response->result->data;

    //Check for plugin
    if ($data->plugin->key == 'social_login')
    {
    //Operation successfull
    if ($data->plugin->data->status == 'success')
    {
    //The token of the user that signed in/up using his social network account
    $user_token = $data->user->user_token;

    // 1] Check if you have a userID for this token in your database
    $user_id = GetUserIdForUserToken($user_token);

    // 2.1] If the userID is empty then this is the first time that this user signs in
    if ($user_id === null)
    {
    // 2.1.1] Create a new account (optionally display a form to collect more data about the user).
    // Insert you proprietary account creation code here.

    // 2.1.2] Attach the user_token to the userID of the created account.
    LinkUserTokenToUserId ($user_token, $user_id);
    }
    // 2.2] If you DO have an userID for the user_token then this is a returning visitor
    else
    {
    // 2.2.1] The account already exists
    }

    // 3] You either created a new user or read the details of an existing user from your database
    // 3.1] Setup your session/cookies to login the user
    // 3.2] Forward the user to his account dashboard
    }
    }
    }
    }
    ?>CODE]

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    The error actually gives you everything you need to know. Take a look at this line:

    PHP Code:
    $user_id GetUserIdForUserToken($user_token); 
    See how it's calling a function named GetUserIdForUserToken()?

    There is no function named GetUserIdForUserToken() that's been declared anywhere in the script, hence the error:

    Code:
    ...undefined function GetUserIdForUserToken()
    because the function GetUserIdForUserToken() is not defined.

    Does the script come with any other files that are supposed to be require()-d by this file? Perhaps files that contain functions named GetUserIdForUserToken()? If not, then there's nothing that can be done.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles