PHP code example of ornicar / github-api
1. Go to this page and download the library: Download ornicar/github-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ornicar / github-api example snippets
$github = new Github_Client();
$myRepos = $github->getRepoApi()->getUserRepos('ornicar');
Github_Autoloader::register();
$github = new Github_Client();
$users = $github->getUserApi()->search('ornicar');
$user = $github->getUserApi()->show('ornicar');
$github->getUserApi()->update('ornicar', array('location' => 'France', 'blog' => 'http://diem-project.org/blog'));
$users = $github->getUserApi()->getFollowing('ornicar');
$users = $github->getUserApi()->getFollowers('ornicar');
$github->getUserApi()->follow('symfony');
$github->getUserApi()->unFollow('symfony');
$users = $github->getUserApi()->getWatchedRepos('ornicar');
$emails = $github->getUserApi()->getEmails();
$github->getUserApi()->addEmail('[email protected] ');
$github->getUserApi()->removeEmail('[email protected] ');
$issues = $github->getIssueApi()->getList('ornicar', 'php-github-api', 'open');
$issues = $github->getIssueApi()->search('ornicar', 'php-github-api', 'closed', 'bug');
$issue = $github->getIssueApi()->show('ornicar', 'php-github-api', 1);
$github->getIssueApi()->open('ornicar', 'php-github-api', 'The issue title', 'The issue body');
$github->getIssueApi()->close('ornicar', 'php-github-api', 4);
$github->getIssueApi()->reOpen('ornicar', 'php-github-api', 4);
$github->getIssueApi()->update('ornicar', 'php-github-api', 4, array('body' => 'The new issue body'));
$comments = $github->getIssueApi()->getComments('ornicar', 'php-github-api', 4);
$github->getIssueApi()->addComment('ornicar', 'php-github-api', 4, 'My new comment');
$labels = $github->getIssueApi()->getLabels('ornicar', 'php-github-api');
$github->getIssueApi()->addLabel('ornicar', 'php-github-api', 'label name', 4);
$github->getIssueApi()->removeLabel('ornicar', 'php-github-api', 'label name', 4);
$github->getIssueApi()->searchLabel('ornicar', 'php-github-api', 'label name')
$commits = $github->getCommitApi()->getBranchCommits('ornicar', 'php-github-api', 'master');
$commits = $github->getCommitApi()->getFileCommits('ornicar', 'php-github-api', 'master', 'README');
$commit = $github->getCommitApi()->getCommit('ornicar', 'php-github-api', '726eac09a3b44411bd86');
$tree = $github->getObjectApi()->showTree('ornicar', 'php-github-api', '691c2ec7fd0b948042047b515886fec40fe76e2b');
$blobs = $github->getObjectApi()->listBlobs('ornicar', 'php-github-api', '691c2ec7fd0b948042047b515886fec40fe76e2b');
$blob = $github->getObjectApi()->showBlob('ornicar', 'php-github-api', '691c2ec7fd0b948042047b515886fec40fe76e2b', 'CHANGELOG');
$rawText = $github->getObjectApi()->getRawData('ornicar', 'php-github-api', 'bd25d1e4ea7eab84b856131e470edbc21b6cd66b');
$repos = $github->getRepoApi()->search('symfony');
$repos = $github->getRepoApi()->search('chess', 'php');
$repos = $github->getRepoApi()->search('chess' , 'php', 2);
$repo = $github->getRepoApi()->show('ornicar', 'php-github-api')
$repos = $github->getRepoApi()->getUserRepos('ornicar');
$repos = $github->getRepoApi()->getPushableRepos();
$repo = $github->getRepoApi()->create('my-new-repo', 'This is the description of a repo', 'http://my-repo-homepage.org', true);
$repo = $github->getRepoApi()->setRepoInfo('username', 'my-new-repo', array('description' => 'some new description'));
$token = $github->getRepoApi()->delete('my-new-repo'); // Get the deletion token
$github->getRepoApi()->delete('my-new-repo', $token); // Confirm repository deletion
$github->getRepoApi()->setPublic('reponame');
$github->getRepoApi()->setPrivate('reponame');
$keys = $github->getRepoApi()->getDeployKeys('reponame');
$keys = $github->getRepoApi()->addDeployKey('reponame', 'key title', $key);
$keys = $github->getRepoApi()->removeDeployKey('reponame', 12345);
$collaborators = $github->getRepoApi()->getRepoCollaborators('username', 'reponame');
$collaborators = $github->getRepoApi->addCollaborator('reponame', 'username');
$collaborators = $github->getRepoApi->removeCollaborator('reponame', 'username');
$repository = $github->getRepoApi->watch('ornicar', 'php-github-api');
$repository = $github->getRepoApi->unwatch('ornicar', 'php-github-api');
$repository = $github->getRepoApi->fork('ornicar', 'php-github-api');
$tags = $github->getRepoApi()->getRepoTags('ornicar', 'php-github-api');
$tags = $github->getRepoApi()->getRepoBranches('ornicar', 'php-github-api');
$watchers = $github->getRepoApi()->getRepoWatchers('ornicar', 'php-github-api');
$network = $github->getRepoApi()->getRepoNetwork('ornicar', 'php-github-api');
$contributors = $github->getRepoApi()->getRepoLanguages('ornicar', 'php-github-api');
$contributors = $github->getRepoApi()->getRepoContributors('ornicar', 'php-github-api');
$contributors = $github->getRepoApi()->getRepoContributors('ornicar', 'php-github-api', true);
$openPullRequests = $github->getPullRequestApi()->listPullRequests( "ezsystems", "ezpublish", 'open' );
$openPullRequests = $github->getPullRequestApi()->listPullRequests( "ezsystems", "ezpublish" );
$closedPullRequests = $github->getPullRequestApi()->listPullRequests( "ezsystems", "ezpublish", 'closed' );
$pullRequest15 = $github->getPullRequestApi()->show( "ezsystems", "ezpublish", 15 );
$title = "My nifty pull request";
$body = "This pull request contains a bunch of enhancements and bug-fixes, happily shared with you";
$github->getPullRequestApi()->create( "ezsystems", "ezpublish", "master", "testbranch", $title, $body );
$issueId = 15;
$github->getPullRequestApi()->create( "ezsystems", "ezpublish", "master", "testbranch", null, null, $issueId );
$repo = $github->get('repos/show/ornicar/php-github-api');
$github->authenticate($username, $secret, $method);
$github->deAuthenticate();
$github->getHttpClient()->setOption('user_agent', 'My new User Agent');
// create a custom http client
class MyHttpClient extends Github_HttpClient
{
public function doRequest($url, array $parameters = array(), $httpMethod = 'GET', array $options = array())
{
// send the request and return the raw response
}
}
$github = new Github_Client(new MyHttpClient());
$github->setHttpClient(new MyHttpClient());
// create a custom User API
class MyGithubApiUser extends Github_Api_User
{
// overwrite things
}
$github->setApi('user', new MyGithubApiUser($github));