2017 © Pedro Peláez
 

library simple-php-github-api

simple php github api

image

diversen/simple-php-github-api

simple php github api

  • Tuesday, February 16, 2016
  • by diversen
  • Repository
  • 3 Watchers
  • 11 Stars
  • 370 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 17 Versions
  • 2 % Grown

The README.md

About

Very simple github API for PHP using OAuth. 37 LOC for the API class. And a curl helper class with 84 LOC., (*1)

Install simple-php-github-api

php composer.phar require diversen/simple-php-github-api:

Or if you have placed composer.phar in your path as composer, (*2)

composer require diversen/simple-php-github-api

Brief explantion.

There is really only tree methods you can do. Let us see those three methods first. (Further below is an complete example using the built-in server for easy testing)., (*3)

1) Generate an access URL to github.com, (*4)

~~~.php $access_config = array ( 'redirect_uri' => GITHUB_CALLBACK_URL, 'client_id' => GITHUB_ID, 'state' => md5(uniqid()), 'scope' => 'user' );, (*5)

$api = new githubapi(); $url = $api->getAccessUrl($access_config); echo "Github Login";, (*6)


2) Callback from github.com ~~~.php $access_config = array ( 'redirect_uri' => GITHUB_CALLBACK_URL, 'client_id' => GITHUB_ID, 'client_secret' => GITHUB_SECRET ); $api = new githubapi(); $res = $api->setAccessToken($access_config); if ($res) { // OK This is where we will call the api header("Location: /api_call.php"); } else { // Not OK. echo errors echo "Could not get access token. Errors: <br />"; print_r($api->errors); }

3) API call, (*7)

For full listing see: https://developer.github.com/v3/, (*8)

~~~.php // We have a access token and we can now call the api: $api = new githubapi();, (*9)

// Simple call - API get current users credentials // This can also be done without scope, (*10)

// example // $command = '/user', // $request = 'GET', 'POST' or 'PATCH' or 'DELETE' etc. Se API: // $post = variables to POST array, (*11)

$command = "/user"; $res = $api->apiCall($command, $request = null, $post = null); if (!$res) { print_r($api->errors); die; } else { print_r($res); } ~~~, (*12)

Full example

Example you can run right away using the built-in PHP-server., (*13)

Make a github app

Log into github.com, (*14)

Register a new application at https://github.com/settings/developers, (*15)

You will see something like this:, (*16)

My settings, (*17)

Create your app., (*18)

Enter base_dir of the simple-php-github-api:, (*19)

cd vendor/diversen/simple-php-github-api

Configuration

cp example/config.php-dist example/config.php

Edit config, (*20)

Set config in example/config.php according to above settings and the screenshot above., (*21)

Run test-server with example:, (*22)

php -S localhost:8080 -t example/

More github API info

For full listing of all API calls check:, (*23)

https://developer.github.com/v3/, (*24)

Scope:, (*25)

https://developer.github.com/v3/oauth/#scopes, (*26)

I have not tested many calls - but you should be able to use all. E.g. POST, or PATCH, DELETE., (*27)

Support

Create an issue, and Let me hear if it does not work out for you., (*28)

The Versions

16/02 2016

dev-master

9999999-dev http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

16/02 2016

1.1.3

1.1.3.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

23/10 2015

1.1.2

1.1.2.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

21/10 2015

1.0.912

1.0.912.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

21/10 2015

1.1.1

1.1.1.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

05/08 2015

1.0.10

1.0.10.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

05/08 2015

1.0.11

1.0.11.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

05/08 2015

1.0.91

1.0.91.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

05/08 2015

1.0.911

1.0.911.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

api github

05/08 2015

1.0.9

1.0.9.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

github

05/08 2015

1.0.8

1.0.8.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

github

05/08 2015

1.0.7

1.0.7.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

github

05/08 2015

1.0.5

1.0.5.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

github

05/08 2015

1.0.4

1.0.4.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

 

github

13/12 2013

1.0.3

1.0.3.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

  • diversen/simple-php-curl-wrapper 1.0.1
  • php >=5.3.0

 

github

17/04 2013

1.0.2

1.0.2.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

github

11/04 2013

1.0.1

1.0.1.0 http://github.com/diversen/simple-php-github-api

simple php github api

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

markdown