public
Description: Yet another github badge
Homepage: http://ben.pixelmachine.org
Clone URL: git://github.com/schleyfox/yaghb.git
yaghb / yaghb.php
100644 29 lines (28 sloc) 0.861 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
<?php if($_GET['username']){ ?>
var user = (<?php
  $username = urlencode($_GET['username']);
  $ch = curl_init();
  $timeout = 5; // set to zero for no timeout
  curl_setopt ($ch,CURLOPT_URL,"http://github.com/api/v1/json/$username");
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $file_contents = curl_exec($ch);
  curl_close($ch);
  echo $file_contents;
?>);
var projects = user['user'];
var ul = document.getElementById('yaghb');
var repos = projects['repositories'];
var n = repos.size();
for(var i = 0; i < n; i++) {
repo = repos[i];
var li = document.createElement('li');
var a = document.createElement('a');
a.href = repo['url'];
a.title = repo['description'];
var txt = document.createTextNode(repo['name']);
a.appendChild(txt);
li.appendChild(a);
ul.appendChild(li);
}
<?php } ?>