-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart.php
More file actions
94 lines (74 loc) · 2.23 KB
/
start.php
File metadata and controls
94 lines (74 loc) · 2.23 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
session_start();
//open connection
$ch = curl_init();
$url = 'https://api.sandbox.slcedu.org/api/rest/v1/students';
//$url = 'https://api.sandbox.slcedu.org/api/rest/system/session/check';
$token = $_SESSION['access_token'];
$code = $_SESSION['code'];
$auth = sprintf('Authorization: bearer %s', $token);
//echo $auth;
$headers = array(
'Content-Type: application/vnd.slc+json',
'Accept: application/vnd.slc+json',
$auth);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
if (DISABLE_SSL_CHECKS == TRUE) {
// WARNING: this would prevent curl from detecting a 'man in the middle' attack
// See note in settings.php
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
}
//execute post
$result = curl_exec($ch);
// echo $result;
$json = json_decode($result);
// If response is '401 Unauthorized', redirect back to home page for authentication
if ($json->code == '401') {
header('Location: index.php');
die();
}
//https://localhost/api/rest/v1/teachers/<UUID>/teacherSectionAssociations/sections
//foreach($json as $students) {
// $found = false;
// foreach($students->links as $links) {
// //echo $links->rel;
// if ($links->rel == "getStudentSectionAssociations" && !$found) {
// $url = $links->href;
// //echo $url . "<br/>";
// curl_setopt($ch, CURLOPT_URL, $url);
// $sections_result = curl_exec($ch);
// print_r($sections_result);
// $found = true;
// }
// }
//}
//close connection
curl_close($ch);
?>
<html>
<head>
<link rel="stylesheet" href="jq-mobile/jquery.mobile-1.1.0.min.css" />
<script src="jq-mobile/jquery-1.7.2.min.js"></script>
<script src="jq-mobile/jquery.mobile-1.1.0.min.js"></script>
</head>
<body>
<div data-role="header" data-position="fixed">
<h1>ClassView</h1>
</div>
<ul data-role="listview" data-theme="g">
<?php
foreach ($json as $student) {
echo sprintf('<li><a href="student.php?UUID=%s">', $student->id);
echo $student->name->firstName . ' ' . $student->name->lastSurname;
echo '</a></li>';
}
?>
</ul>
<div data-role="footer" data-position="fixed">
<h1></h1>
</div>
</body>
</html>