simivar / genius-php
Genius PHP is a open source library that allows you to access Genius API from your PHP application. Supports every resource.
Installs: 141 494
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 4
Forks: 3
Open Issues: 3
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- myclabs/php-enum: ^1.8
- php-http/client-common: ^2.0
- php-http/discovery: ^1.13
- php-http/httplug: ^2.0
- php-http/message: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.8
- http-interop/http-factory-guzzle: ^1.0
- php-http/guzzle7-adapter: ^1.0
- phpstan/phpstan: ^0.12.85
- phpstan/phpstan-phpunit: ^0.12.18
- phpunit/phpunit: ^8.5
README
Genius PHP is a open source library that allows you to access Genius API from your PHP application. It supports oAuth 2 from version 1.0.
Getting started
Genius PHP is avialable via Composer. Version 1.0 does not implement HTTP Client on it's own anymore and uses HTTPlug abstraction so you are free to choose any HTTP Client you want that depends on php-http/client-implementation virutal package.
composer require simivar/genius-php php-http/message php-http/guzzle6-adapter
Static Bearer example
<?php require_once('vendor/autoload.php'); $authentication = new \Http\Message\Authentication\Bearer('YOUR_ACCESS_TOKEN'); $genius = new \Genius\Genius($authentication); $upvoteAnnotation = $genius->getAnnotationsResource()->get(11852248);
OAuth2 Example
require_once('vendor/autoload.php'); $authentication = new \Genius\Authentication\OAuth2( 'YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_REDIRECT_URL', new \Genius\Authentication\ScopeList([ \Genius\Enum\Scope::ME(), \Genius\Enum\Scope::CREATE_ANNOTATION(), \Genius\Enum\Scope::MANAGE_ANNOTATION(), \Genius\Enum\Scope::VOTE(), ]), null ); $accessTokenFromDatabase = 'get access token from DataBase here'; if ($accessTokenFromDatabase === null) { $authorizeUrl = $authentication->getAuthorizeUrl(); // redirect user to $authorizeUrl } else { $authentication->setAccessToken($accessTokenFromDatabase); } $genius = new \Genius\Genius($authentication); $upvoteAnnotation = $genius->getAnnotationsResource()->get(11852248);
Complete documentation, installation instructions, and examples are available at: http://simivar.github.io/Genius-PHP/.
Versioning
Genius PHP is created using Semver. All minor and patch updates are backwards compatibile. 0.1
branch is no longer maintained.
License
Please see the license file for more information.