Skip to content

Commit

Permalink
added connections scope as example
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkisDev committed Jun 3, 2021
1 parent c658f7a commit 8ed0f19
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion demo/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$secret_id = "";

# SCOPES SEPARATED BY SPACE
# example: identify email guilds
# example: identify email guilds connections
$scopes = "";

# REDIRECT URL
Expand Down
2 changes: 1 addition & 1 deletion demo/includes/discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function get_guild($id)
function get_connections()
{
$url = $GLOBALS['base_url'] . "/api/users/@me/connections";
$headers = array ('Content-Type: application/x-www-form-urlencoded', 'Authorization: Bearer ' . $_SESSION['access_token']);
$headers = array('Content-Type: application/x-www-form-urlencoded', 'Authorization: Bearer ' . $_SESSION['access_token']);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand Down
4 changes: 2 additions & 2 deletions demo/includes/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$_SESSION['guilds'] = get_guilds();

# Fetching user connections | (connections scope)
# $_SESSION['connections'] = get_connections();
$_SESSION['connections'] = get_connections();

# Redirecting to home page once all data has been fetched
redirect("../index.php");
44 changes: 24 additions & 20 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,33 @@
?>
</table>
<br>
<h2> User Guilds Response :</h2>
<div class="response-block"><p> <?php echo json_encode($_SESSION['guilds']); ?></p></div>
<br>
<h2> User Connections :</h2>
<h2> User Guilds Response :</h2>
<div class="response-block">
<p> <?php echo json_encode($_SESSION['guilds']); ?></p>
</div>
<br>
<h2> User Connections :</h2>
<table border="1">
<tr>
<th>NAME</th>
<th>ID</th>
</tr>
<?php
for($i = 0; $i < sizeof($_SESSION['connections']); $i++) {
echo "<tr><td>";
echo $_SESSION['connections'][$i]['name'];
echo "<td>";
echo $_SESSION['connections'][$i]['type'];
echo "</td>";
echo "</tr></td>";
}
?>
<tr>
<th>NAME</th>
<th>TYPE</th>
</tr>
<?php
for ($i = 0; $i < sizeof($_SESSION['connections']); $i++) {
echo "<tr><td>";
echo $_SESSION['connections'][$i]['name'];
echo "<td>";
echo $_SESSION['connections'][$i]['type'];
echo "</td>";
echo "</tr></td>";
}
?>
</table>
<br>
<h2> User Connections Response :</h2>
<div class="response-block"><p> <?php echo json_encode($_SESSION['connections']); ?></p></div>
<h2> User Connections Response :</h2>
<div class="response-block">
<p> <?php echo json_encode($_SESSION['connections']); ?></p>
</div>
</body>

</html>

0 comments on commit 8ed0f19

Please sign in to comment.