Beispiel #1
0
/**
 * Authenticate the user by username and password and then by Messente's verification widget.
 * @param type $username
 * @param type $password
 */
function authenticate($username, $password)
{
    // Primitive and unsecure authentication just for illustrating this example
    if ($username == 'test' && $password == '1234') {
        $request_params = array('user' => MESSENTE_API_USERNAME, 'version' => VERSION, 'callback_url' => CALLBACK_URL);
        // Add phone number if it was submitted
        if (isset($_POST['phone']) && !empty($_POST['phone'])) {
            $request_params['phone'] = $_POST['phone'];
        }
        // Initialize signature calculation object
        $signer = new Signer();
        // Generate signature
        $sig = $signer->generateSignature($request_params, MESSENTE_API_PASSWORD);
        // Add signature to array
        $request_params['sig'] = $sig;
        // Redirect to Messente
        verify($request_params);
    } else {
        goBack('Wrong credentials!');
    }
}