-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
67 lines (54 loc) · 1.48 KB
/
example.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/////////////////////////////////////////////////
// Preamble
//
// To get a clientID, visit https://id.scene.org/docs/
include_once("sceneid3.inc.php");
$sceneID = new SceneID3( array(
"clientID" => "myPortalClientID",
"clientSecret" => "verySecretHashThing",
"redirectURI" => "http://my.domain.tld/return.url",
) );
/////////////////////////////////////////////////
// Act 1 - Operations that don't require login
//
// First, we get a client-token.
try
{
// this is optional to call explicitly
// resource calls will automatically call this
// if there's no access token claimed yet.
$sceneID->GetClientCredentialsToken();
// We got it, now we can query at will
$result = $sceneID->User(1);
print_r($result);
}
catch( SceneID3AuthException $e )
{
// something went wrong
}
/////////////////////////////////////////////////
// if we want to invalidate the previous token
// we can call Reset()
$sceneID->Reset();
/////////////////////////////////////////////////
// Act 2 - Operations that do require a user
//
// This is a bit trickier
// First, we redirect to the SceneID login page
$sceneID->PerformAuthRedirect();
// After that, on the redirect page, we process
// the response sent by SceneID
try
{
$sceneID->ProcessAuthResponse();
// Note: this only needs to be done once, the tokens are stored in sessions
// We can now identify the user by their login
$result = $sceneID->Me();
print_r($result);
}
catch (Exception $e)
{
// something went wrong
}
?>