tan-tan-kanarek / github-php-client Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The documentation is a bit uncomplete. How can I get the issues of a repo?
hey, i'm want show the files included on commit. but i dont find the function to do it.
What's the purpose of isArray
? It doesn't seem to be used anywhere. Can it be removed?
I'm confused about how to get a list of milestones in a repository.
In GitHubIssuesLabels.php you have listAllLabelsForThisRepository()
which lists the labels, and getSingleLabel()
which gets a single label. This makes sense.
But in GitHubIssuesMilestones.php you have listMilestonesForRepository()
which does not list milestones but rather gets a single milestone.
Do you have an example of using OAuth integration? I'm writing a GitHub application which the user authorises and needs to fetch their repositories etc.
Hi - the library is great - thanks!
But could you create an official version tag and publish that to packagist? I'm trying to use the library in a project but don't want to set the minimum stability to dev if I can avoid it!
Thanks!
Please fix it.
Do you have an idea what might be wrong, I have checked the CURL and the username and password is being passed on ...
class Github {
private $username = NULL;
private $password = NULL;
private $client = NULL;
public function __construct($username=NULL, $password=NULL) {
$this->username = $username;
$this->password = $password;
$this->client = new GitHubClient();
$this->client->setCredentials($username, $password);
}
public function listRepos() {
return $this->client->repos->listYourRepositories();
}
Hi. I try install this package with composer. Installed version of library is very old, as i understand. Please update composer package if you can. Thanks.
Hey,
i'm trying show my repos list but i get an object private. i cant read for exemple the id or name or full_name. how can i read it?
The issue probably occurs because the deprecated members API is used in
getTeamMember()
:addTeamMember()
:removeTeamMember()
:Accordingly to https://developer.github.com/v3/orgs/teams/,
/memberships/
should be used instead of /members/
and response codes are different.
Hello!
Just wondering if there is anyway to get the comment left when someone commits? Something like:
$commit->getComment();
Thanks
https://github.com/tan-tan-kanarek/github-php-client/blob/master/client.md#methods-31
The name of the method is quite misleading as it actually removes the member from the organization.
So what's the real purpose of it?
Please fix it.
Please fix it.
function delete repository work very well.
but create is not work
i think
case PATCH:
not implementate
This class is specified as return for some GitHubRepoContents
methods. e.g.:
But I can't find any trace of that class anywhere except for this issue: #96
Here's the stack trace:
Stack trace:
.../vendor/tan-tan-kanarek/github-php-client/client/GitHubClientBase.php(355): GitHubClientBase->parseResponse('...', Object(stdClass), 'GitHubRepoConte...', 201, false)
.../vendor/tan-tan-kanarek/github-php-client/client/services/GitHubReposContents.php(59): GitHubClientBase->request('...', 'PUT', Array, 201, 'GitHubRepoConte...')
...index.php(15): GitHubReposContents->createFile('username', 'repo', 'file.txt', 'message', '...encoded content...')
{main}
thrown in ...vendor/tan-tan-kanarek/github-php-client/client/GitHubClientBase.php on line 437
Does this class need to be defined, or is the return type wrong?
Hello there! I am really really new at this, how do I "install" this? please help ^^
Does $client->setCredentials('user', 'pass');
work for private repos?
What pre-req's are there to gain api access to private repo's from your client?
Hello There! Thank you for creating this awesome API.
Unfortunately, I have some issues with it. I am currently attempting to connect with OAuth however I keep receiving 404 responses. Do you perhaps have some code examples or guides on how to set this up?
Thank you,
Bart
The example pagination code from your readme fails when there are fewer objects than the page size. That is: your example gets commit messages 4 at a time. If pointed at a repo with fewer than 4 commits, such as https://github.com/ryandesign/test-fairly-empty which has 2 commits, it fails:
$ php test-pagination.php
================ Page 1 - 2 items ================
a6a3406f266c8ad5e8d6ea910c22bb54a70bd5db - Update README.md
d0b8d67f5ff769d9f39e975193e51beededde406 - Initial commit
PHP Fatal error: Uncaught GitHubClientException: Page not defined in /path/to/github-php-client/client/GitHubClientBase.php:166
Stack trace:
#0 /path/to/test-pagination.php(31): GitHubClientBase->getNextPage()
#1 {main}
thrown in /path/to/github-php-client/client/GitHubClientBase.php on line 166
Fatal error: Uncaught GitHubClientException: Page not defined in /path/to/github-php-client/client/GitHubClientBase.php:166
Stack trace:
#0 /path/to/test-pagination.php(31): GitHubClientBase->getNextPage()
#1 {main}
thrown in /path/to/github-php-client/client/GitHubClientBase.php on line 166
As long as page size is set less than or equal to the number of items, the example works, but of course that defeats the purpose since I don't know in advance how many items there are and I want to set the page size to its maximum value of 100 to minimize the number of requests I send.
In #75 I included some code that made use of the method getTheAuthenticatedUser and in doing so I identified what I thought was a problem.
As implemented the core of the method is this
return $this->client->request("/user", 'GET', $data, 200, 'GitHubPrivateUser');
The problem is GitHubPrivateUser is only interested/able to use a very narrow subset of the data that GitHub passes back.
GitHubPrivateUser is only interested in
array(
'total_private_repos' => 'int',
'owned_private_repos' => 'int',
'private_gists' => 'int',
'disk_usage' => 'int',
'collaborators' => 'int',
Whereas the GitHub API actually passes back a great deal extra information.
When used as I've done with Oauth in #75 it is much more useful to be able to access all of the information passed back. As an interim step I've modified getTheAuthenticatedUser so that it is now doing the following
return $this->client->request("/user", 'GET', $data, 200, 'GitHubFullUser');
Is this an improvement? Or is it just plain wrong?
Hi there
I keep getting 401 response when using
$client = new GitHubClient();
$client->oauth->createNewAuthorization($clientId);
Same with webApplicationFlow:
I tried Oauth manually and it works fine.
Am I missing somethings or is there a problem?
When an issue cannot be found, there's currently no recourse other than a mismatched response. (404 instead of 200).
getPage isn't there and I don't see how to detect you've seen (or are on) the last available page.
Error: Uncaught exception 'GitHubClientException' with message 'Expected status [201], actual status [422]
This is a great project, makes it very easy to get going with GitHub. However, I don't see a LICENSE so I'm wondering, what is this license under? Is it GPL compatible?
Thanks,
Sean
G'day
First, thanks for the client. Found it very useful for a project.
It appears that GitHubCommitCommitAuthor is incomplete. It doesn't actually declare the class variables/methods required to actually use it.
No great show stopper. I've been able to make the changes myself.
Wondering if I've missed some important point?
David.
Hello. Sorry about my english. I'd find your github-php-client . I think that it i realy need for my https://github.com/averony/datebott . Please correct me if I'm wrong. Your code allows you to log your experiments at github, and make changes in files of your repository by means of curl? Now I have the task to automate the process of adding new rows in the file https://github.com/averony/datebott/blob/master/woman.js . woman.js - is a database in text form. When you try to use your code I get the following error:
https://github.com/averony/datebott/blob/master/supertest.js
how can I call label for a particular issue
The API docs list "webApplicationFlow" as a method for GitHubOauth. Can't find it in the code and attempts to use it (not suprisingly) get
Fatal error: Call to undefined method GitHubOauth::webApplicationFlow()
It's unclear how to iterate over all pages of results. I can get the first page, the next page, or the last page, but I don't see how to construct a loop that iterates over every page from the first to the last. Your existing sample code assumes there are exactly two pages of results. Your full API reference does not include the pagination functions.
I used listIssues() function and try to fetch open and closed issues but it listing issues as well pull request too. So Is there any way so I can get only list of Issues?
the function name is createComment but it actually deletes the comment (looks like it),
have fixed this problem here: https://github.com/shreyans264/github-php-client
(checkout client/services/GitHubPullsComments.php for same)
plz reply..
Can you make the library compatible with Composer so that I can use it in my Laravel application?
Hi,
i'm using your library and i'm trying to create issue.
There is my code:
$client = new GitHubClient();
$client->setCredentials('username', 'password');
$issue = new GithubIssues($client);
$issue->createAnIssue('name', 'repo', 'title', 'content');
I'm getting a 500 error:
Expected status [201], actual status [400], URL [/repos/nicolasheraly/API-Culture/issues]
Here is the stack trace:
at GitHubClientBase->parseResponse('/repos/nicolasheraly/API-Culture/issues', 'HTTP/1.1 100 ContinueHTTP/1.1 400 Bad RequestServer: GitHub.comDate: Wed, 07 May 2014 15:51:26 GMTContent-Type: application/json; charset=utf-8Status: 400 Bad RequestX-RateLimit-Limit: 5000X-RateLimit-Remaining: 4991X-RateLimit-Reset: 1399480094X-GitHub-Media-Type: github.v3X-XSS-Protection: 1; mode=blockX-Frame-Options: denyContent-Security-Policy: default-src 'none'Content-Length: 89Access-Control-Allow-Credentials: trueAccess-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-IntervalAccess-Control-Allow-Origin: *X-GitHub-Request-Id: BCA56D52:6B89:A1B1689:536A567EStrict-Transport-Security: max-age=31536000X-Content-Type-Options: nosniff{"message":"Problems parsing JSON","documentation_url":"https://developer.github.com/v3"}', 'GitHubIssue', 201, )
in SF_ROOT_DIR/lib/model/github-php-client/client/GitHubClientBase.php line 271 ...
I hope you can help me,
Nicolas Héraly
Hi how can i get rid off the GithubIssue output in listing issues example?
function to edit review comments added, pull request opened
G'day,
Problem
My aim in using this client has been to use it in a web application. The problem is that I don't believe that the client supports GitHub Oauth via web application flow
Possible solution
I've developed a possible solution by combining this client with this PHP OAuth wrapper. The code below is for a simple web application that has the combination working.
To get this working has required some changes to GitHubClient base.
Relevant questions are
<?php
// Combine PHP-OAuth2 and GitHubClient to get details of authenticated user via Oauth web application flow
require('PHP-OAuth2/Client.php');
require('PHP-OAuth2/GrantType/IGrantType.php');
require('PHP-OAuth2/GrantType/AuthorizationCode.php');
require_once( __DIR__ . '/client/client/GitHubClient.php' );
// GitHub client details - need to register here https://github.com/settings/applications/new
// to get values for your script
const CLIENT_ID = '?? replace with your value ??';
const CLIENT_SECRET = '?? replace with your value??';
// redirect URI for app - replace with URI for where you put this script
const REDIRECT_URI = 'http://localhost:8080/oauth_combine.php';
// GitHub Oauth URLs
const AUTHORIZATION_ENDPOINT = 'https://github.com/login/oauth/authorize';
const TOKEN_ENDPOINT = 'https://github.com/login/oauth/access_token';
// Generate a unique state variable
$address=1530;
$STATE= hash('sha256', microtime(TRUE).rand().$address);
// the oauth client
$client = new OAuth2\Client(CLIENT_ID, CLIENT_SECRET);
if (!isset($_GET['code'])) {
// if haven't got a code
// Send user to github oauth login
// PHP-OAuth2 doesn't know about the extras for github
$EXTRAS = Array( 'state' => $STATE, 'scope' => "user" );
$auth_url = $client->getAuthenticationUrl(AUTHORIZATION_ENDPOINT,
REDIRECT_URI, $EXTRAS);
header('Location: ' . $auth_url);
die('Redirect');
} else {
// Got the temp code, need to exchange it for a token so we can get cracking
$params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI);
$EXTRAS = Array( 'state' => $_GET['state'] );
$response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code',
$params, $EXTRAS);
if ( $response['code'] != 200 ) {
// oh dear, that failed
print "<h3> Response was " . $response['code'] . "</h3>";
die;
}
// got a 200 response = success?, parse the response and try to get token
parse_str($response['result'], $info);
if ( array_key_exists( 'access_token', $info ) ) {
print "<h1>Got access token " . $info['access_token'] . "</h1>";
// hand the token over to GitHubClient to start doing the query
$oauth_token = $info['access_token'];
$client = new GitHubClient();
// The following two methods are new additions
$client->setAuthType( 'Oauth' );
$client->setOauthToken( $oauth_token );
$response = $client->users->getTheAuthenticatedUser();
// just dump the output
var_dump( $response );
// the following only works if a change is made to
// services/GitHubUsers.php
print "<h3>Show user details</h3>";
print "<ul> <li> Name: " . $response->getName() . "</li>" .
"<li> Email: " . $response->getEmail() . "</li></ul> ";
} else {
print "<h1> FAILURE - no token </h1>";
print_r( $info );
}
}
Hi,
If you try to access a private repository, an error is obtained.
Sorry, it's me again. Thank you again for the help last time. I finally made it. But the thing is that that is not what I need. Maybe you have a solution for my problem. I need to make changes(Commit changes) to the file base https://github.com/averony/datebott/edit/master/woman.js . Let's say I have a server receives payment, your code works and through curl automatically changes the content in this file. You can implement something similar with your help? Or can you tell me any other solution?
Thanks in advance, you help me a lot.
How can I create an issue with label
I tried this code but it didn't work
$client->issues->createAnIssue('KareemMAX', 'Minecraft-Skiner', $_POST["title"], $_POST["body"],null,null,null,array("Bug tracker"));
Would be great to have documentation for the available methods and objects used by this system.
The problem is, I have no clue what methods map to Github's various endpoints and what given arguments are required or accepted by said methods for the Client library to function...
Hi,
I am trying to retrieve the date of a commit;
foreach($commits as $commit)
{
$c = $commit->getCommit();
$message = $c->getMessage();
$committer = $c->getCommitter(); // EMPTY :(
$author = $c->getAuthor(); // EMPTY :(
...
The $message variable is set perfectly, but unfortunately both $committer and $author are blank when I var_dump them. Is this part not yet implemented perhaps? Or do I do something wrong?
Would hope you can help me out,
Regards,
Gert-Jan
hey, i'm want show the files included on commit. but i dont find the function to do it.
test issue body
Please publish an example with user authentication. Username and password are known.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.