-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathethosProxyGetPersonByGuid.php
More file actions
65 lines (56 loc) · 1.96 KB
/
ethosProxyGetPersonByGuid.php
File metadata and controls
65 lines (56 loc) · 1.96 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
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
<?php
header('Content-Type: application/json');
$apikey="ey-your-api-key-here";
// Setting up ethos specific details
$ethosurl='https://integrateapi.elluciancloud.com';
$authurlpath='/auth';
$apiurlpath='/api/';
$ethosDataModel="persons";
$ethosguid="1111-2222-3333-4444-555";
//TODO Add information to find the GUIDs in the Ellucian ERP systems
//$publishurl='https://integrateapi.elluciancloud.com/publish';
//$checkurl='https://integrateapi.elluciancloud.com/consume';
//$consumeurl='https://integrateapi.elluciancloud.com/consume?lastProcessedID=0&max=1';
// Header options for authentication request
$authOpts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Authorization: Bearer ".$apikey."\r\n" .
"Content-Type: application/json\r\n" .
"charset: UTF-8"
)
);
$authContext = stream_context_create($authOpts);
try {
$authtoken = file_get_contents($ethosurl.$authurlpath, false, $authContext);
if ($authtoken === false){
echo "\r\nWe must have done something wrong because our attempt returned false\r\n";
} else {
//echo "The authorization token is: ".$authtoken;
}
} catch (Exception $e) {
echo "We caught an exeption: " . $e . "\r\n\r\n";
}
// Header options for proxy GET request
$proxyGetOpts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: Bearer ".$authtoken."\r\n" .
"Content-Type: application/vnd.hedtech.s.v2.json\r\n" .
"Accept: application/json",
'timeout' => 60
)
);
$proxyGetContext = stream_context_create($proxyGetOpts);
// Lets use the authtoken to get some data
try {
$getData = file_get_contents($ethosurl.$apiurlpath.$ethosDataModel."/".$ethosguid, false, $proxyGetContext);
if ($getData === false){
echo "\r\nWe must have done something wrong because our attempt returned false\r\n";
} else {
echo json_encode(json_decode($getData), JSON_PRETTY_PRINT);
}
} catch (Exception $e) {
echo "We caught an exeption: " . $e . "\r\n";
}
?>