コード例 #1
0
 public function testGetAuthorizeUrl()
 {
     $p = new PhoneId(123, 'secret', array('redirect_uri' => 'http://localhost/return.php'));
     $expected = 'https://login.phone.id/v2/login?client_id=123&redirect_uri=' . urlencode('http://localhost/return.php') . '&response_type=code';
     $actual = $p->getAuthorizeUrl();
     $this->assertEquals($expected, $actual, 'should build the authorize URL with client_id and redirect_uri');
     $expected = 'https://login.phone.id/v2/login?client_id=123&redirect_uri=' . urlencode('http://www.domain.com/return.php') . '&response_type=code';
     $actual = $p->getAuthorizeUrl(array('redirect_uri' => 'http://www.domain.com/return.php'));
     $this->assertEquals($expected, $actual, 'should override query string parameters from input');
     $expected = 'https://login.phone.id/v2/login?client_id=123&response_type=code';
     $actual = $p->getAuthorizeUrl(array('redirect_uri' => null));
     $this->assertEquals($expected, $actual, 'should override and remove null query string parameters');
     $expected = 'https://login.phone.id/v2/login?client_id=123&redirect_uri=' . urlencode('http://localhost/return.php') . '&response_type=code&extra=value';
     $actual = $p->getAuthorizeUrl(array('extra' => 'value'));
     $this->assertEquals($expected, $actual, 'should append query string parameters from input');
 }
コード例 #2
0
ファイル: login.php プロジェクト: pracucci/phoneid-php-sdk
<?php

require_once __DIR__ . '/../../src/PhoneId/autoload.php';
use PhoneId\PhoneId;
$clientId = '<your client id>';
$clientSecret = '<your client secret>';
$phoneId = new PhoneId($clientId, $clientSecret, array('redirect_uri' => 'http://localhost/phoneid-php-sdk/examples/authentication/return.php'));
// Redirect to Phone.id authorize url
header('Location: ' . $phoneId->getAuthorizeUrl());