Learning More About GitHub Users
Each repository is accompanied by an
owner attribute which contains the username associated with the repository owner. For instance, the owner associated with the project described as
A Zend Framework 1.X and Doctrine 1.2 Integration is
beberlei, who happens to be Benjamin Eberlei, and active contributor to a number of high-profile open source projects, among them Doctrine. We can learn more about
beberlei‘s GitHub activity via the API:
$user = $github->getUserApi()->show('beberlei');
$user variable is an array containing all sorts of interesting tidbits about a particular user, including the country-of-residence, public repository count, and contact information (which I’ve changed to thwart spammers). Here’s a dump of the array contents:
["gravatar_id"]=> string(32) "75f5fb3ddda052e46f1daed314ae69ab"
["company"]=> string(18) "direkt effekt GmbH"
["name"]=> string(16) "Benjamin Eberlei"
["created_at"]=> string(25) "2008/09/30 08:47:34 -0700"
["location"]=> string(7) "Germany"
["blog"]=> string(26) "http://www.whitewashing.de"
["following_count"]=> int(5) ["id"]=> int(26936)
["type"]=> string(4) "User"
["permission"]=> NULL ["followers_count"]=> int(231)
["login"]=> string(8) "beberlei"
["email"]=> string(19) "[email protected]"
Learning More About a Specific GitHub User’s Repositories
As you can see from the
public_repo_count value, user
eberlei is a very active GitHub user. You can retrieve a list of a user’s repositories like this:
$repos = $github->getRepoApi()->getUserRepos('eberlei');
Like the first example, the
$repos variable is an array containing a number of multidimensional arrays. Using the
Yet Another TSP Solution
Observatoire Photographique du Paysage
A simple PHP GitHub API client, Object Oriented, tested and documented. For PHP 5.1 to 5.3.
Provides php-github-api and some front widgets
Allows to add comments to your records.
Easily display configurable google maps
Performing Restricted Tasks on GitHub
So far this overview of the GitHub API has focused on publicly accessible data. However, the API also supports quite a few capabilities which are available only to an authenticated user. To authenticate your account, use the
authenticate() method, providing your GitHub username and either your password or API token (the latter of which you can retrieve from your GitHub account management console). The
authenticate() method can accept either the password or token as its second parameter:
Once authenticated, you can carry out all sorts of useful tasks associated with account or repository management, such as updating a repository description:
$repo = $github->getRepoApi()
->setRepoInfo('wjgilmore', 'z2d2', array('description' => 'some new
In addition to changing subscriptions, you can toggle repository visibility (public or private), create and delete repositories, and even add collaborators. See the php-github-api documentation for all of the details.
Have you done anything interesting with the GitHub API, or regularly use a third-party service? Tell us about it in the comments!