-
Notifications
You must be signed in to change notification settings - Fork 0
/
finalprojects.php
82 lines (66 loc) · 1.8 KB
/
finalprojects.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Projects</title>
<link rel="stylesheet" href="fp.css">
</head>
<body>
<?php
require_once('header.php');
?>
<?php
echo '<section class="our_projects">';
$url = "https://api.github.com/orgs/OpenLake/repos";
$apiKey = "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";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: token {$apiKey}",
"User-Agent: My-App",
]);
$response = curl_exec($ch); /*boolean flag*/
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); // Get the HTTP status code
if ($httpCode === 200)
{
$repositories = json_decode($response, true);
if ($repositories)
{
echo '<br><br><br>';
echo '<div class="titleproject">Our Projects</div>';
echo '<br><br><br>';
echo '<div class="all-projects">';
foreach ($repositories as $repository)
{ echo '<a href="indiv_proj.php?repo=' . $repository['name'] . '">';
echo '<div class="project-container">';
echo '<br><br><br>';
echo '<div id="project-head">';
echo $repository['name'];
echo '</div>';
echo '<br>';
echo '<div class="repo-desc">' . $repository['description'] . '</div>';
echo '</div>';
echo '</a>';
echo '<br><br><br>';
}
}
else
{
echo "No repositories found.";
}
}
else
{
echo "Failed to fetch repositories. Error: " . $httpCode;
}
curl_close($ch);
?>
</div>
</div>
<?php
require_once('footer.php');
?>
</body>
</html>