I have a question about GitHub API. I'm just starting to learn it. Sorry for my mistakes.
I need to get a list of users using GitHub API. But I cannot figure out how to do it :(
I would be extremely grateful to you for your help!
That is what we have now:
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<title>GITHUB - API Test</title>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<div id="ghapidata"></div>
<script type="text/javascript">
$(function() {
$('#ghapidata').html('Loading...');
var username = $('#ghusername').val();
var requri = 'https://api.github.com/users/' + "Test";
var repouri = 'https://api.github.com/users/' + "Test" + '/repos';
requestJSON(requri, function(json) {
var fullname = json.name;
var username = json.login;
var aviurl = json.avatar_url;
var profileurl = json.html_url;
var location = json.location;
var followersnum = json.followers;
var followingnum = json.following;
var reposnum = json.public_repos;
var email = json.email;
if (fullname == undefined) {
fullname = username;
}
var outhtml = '<h2>'+ 'Username:' + fullname + ' <span class="smallname">(@<a href="' + profileurl + '" target="_blank">' + username + '</a>)</span></h2>';
outhtml = outhtml + '<a href="' + profileurl + '" target="_blank"><img src="' + aviurl + '" width="80" height="80" alt="' + username + '"></a>';
outhtml = outhtml + '<p>Subscribers: ' + followersnum + ' - Subscribe: ' + followingnum +'</p>';
outhtml = outhtml + '<div class="clearfix">';
var repositories;
$.getJSON(repouri, function(json) {
repositories = json;
outputPageContent();
});
function outputPageContent() {
outhtml = outhtml + '</ul></div>';
$('#ghapidata').html(outhtml);
}
});
function requestJSON(url, callback) {
$.ajax({
url: url,
complete: function(xhr) {
callback.call(null, xhr.responseJSON);
}
});
}
});
</script>
</body>
</html>