-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracker.php
More file actions
48 lines (37 loc) · 1.37 KB
/
tracker.php
File metadata and controls
48 lines (37 loc) · 1.37 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
<?php
# Set your Github username
$githubUsername = "markusprograms";
?>
<!DOCTYPE html>
<?php
$githubUrl = "https://api.github.com/users/$githubUsername";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $githubUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0");
$githubRaw = curl_exec($ch);
curl_close($ch);
$githubParsed = json_decode($githubRaw);
$githubFollowers = $githubParsed->followers;
$githubLikes = 0;
$i = 1;
while (true) {
$githubUrl = "https://api.github.com/users/$githubUsername/repos?page=$i";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $githubUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0");
$githubRaw = curl_exec($ch);
curl_close($ch);
$githubParsed = json_decode($githubRaw);
for ($j = 0; $j < count($githubParsed); $j ++) {
$githubLikes += $githubParsed[$j]->stargazers_count;
}
if (count($githubParsed) != 30) {
break;
}
$i ++;
}
echo "Github followers: $githubFollowers<br>";
echo "Github likes: $githubLikes";
?>