Download the PHP package diversen/simple-php-github-api without Composer

On this page you can find all versions of the php package diversen/simple-php-github-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-php-github-api

About

Very simple github API for PHP using OAuth. 37 LOC for the API class. And a curl helper class with 84 LOC.

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

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).

1) Generate an access URL to github.com

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

$api = new githubapi(); $url = $api->getAccessUrl($access_config); echo "<a href=\"$url\">Github Login";


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

For full listing see: https://developer.github.com/v3/

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

// Simple call - API get current users credentials // This can also be done without scope

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

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



# Full example

Example you can run right away using the built-in PHP-server. 

## Make a github app

Log into [github.com](github.com)

Register a new application at [https://github.com/settings/developers](https://github.com/settings/developers)

You will see something like this: 

![My settings](https://raw.githubusercontent.com/diversen/simple-php-github-api/master/github-api.png "My settings")

Create your app. 

Enter base_dir of the `simple-php-github-api`:

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

## Configuration

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

Edit config

Set config in `example/config.php` according to above settings and 
the screenshot above.

Run test-server with example:

    php -S localhost:8080 -t example/

## More github API info

For full listing of all API calls check: 

[https://developer.github.com/v3/](https://developer.github.com/v3/)

Scope: 

[https://developer.github.com/v3/oauth/#scopes](https://developer.github.com/v3/oauth/#scopes)

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

## Support

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

All versions of simple-php-github-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
diversen/mycurl Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package diversen/simple-php-github-api contains the following files

Loading the files please wait ....