forked from unholybl00d/php-api-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_openid.php
More file actions
40 lines (31 loc) · 1.05 KB
/
example_openid.php
File metadata and controls
40 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once('MxitAPI.php');
try {
$key = 'f00df00df00df00df00df00df00df00d';
$secret = 'f00df00df00df00df00df00df00df00d';
$api = new MxitAPI($key, $secret);
if (isset($_GET) && count($_GET)) {
if ($api->authentication_status() === TRUE) {
$api->get_user_token($_GET['code'], 'http://www.example.com');
$user_id = $api->validate_token();
if ($user_id === FALSE) {
echo 'ERROR: Unable to authenticate user';
} else {
echo '<pre>';
$api->get_app_token('profile/public');
$profile = $api->get_basic_profile($user_id);
var_dump($profile);
echo '</pre>';
}
} else {
echo 'Authentication failed<br />';
echo 'Error: '. $_GET['error'] .'<br />';
echo 'Error Description: '. $_GET['error_description'] .'<br />';
}
} else {
$api->authenticate('http://www.example.com');
}
} catch (Exception $e) {
echo $e->getMessage();
}
?>