Download the PHP package gozfly/gozfly-api-php-client without Composer
On this page you can find all versions of the php package gozfly/gozfly-api-php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gozfly/gozfly-api-php-client
More information about gozfly/gozfly-api-php-client
Files in gozfly/gozfly-api-php-client
Package gozfly-api-php-client
Short Description Gozfly API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on Gozfly. Examples. Documentation.
License MIT
Homepage https://www.github.com/gozfly/gozfly-api-php-client
Informations about the package gozfly-api-php-client
Gozfly API Client with OAuth 2 authorization written on PHP
See index.php to get started.
Installation
Use composer package manager
Or add this package as dependency to composer.json
.
If you have never used Composer, you should start here and install composer.
Usage
To start working with Gozfly API, you will need to get application client id and secret.
Go to Gozfly Developers portal and create new application in section My Apps.
Bootstrapping autoloader and instantiating a client
Getting local redirect URL
To start linking process you have to setup redirect url.
You can set your own or use current one.
SDK provides you a getRedirectUrl()
helper for your convenience:
We recommend you to have it stored during the linking session because you will need to use it when you will be getting access token.
Setting local redirect URL
Set a custom redirect url use:
Getting Gozfly redirect URL
In order of performing OAUTH 2.0 flow, you should get Gozfly login URL.
During this procedure you have to define scope of requested permissions.
Use Scope
enum class to get scope names.
To get redirect url to Gozfly, use the following approach:
Now you can take user to Gozfly. You can use link or rely on Location HTTP header.
Getting Access Token
To get access token use (don't forget to set redirect url)
This method returns object of Gozfly\AccessToken
class.
You can store this token in the file like this:
This way of storing tokens is not recommended due to security concerns and used for demonstration purpose. Please, ensure that tokens are stored securely.
Setting Access Token
You can use method setAccessToken()
for the Gozfly\Client
class to set token stored as string. You have to pass
instance of Gozfly\AccessToken
to this method.
Performing API calls
All API calls can be called through simple method:
There are two helper methods:
Examples
Perform api call to get profile information
List companies where you are an admin
Share content on a personal profile
Share content on a Gozfly business page
Setup custom API request headers
Change default API root
Contributing
Please, open PR with your changes linked to an GitHub issue. You code must follow PSR standards and have PHPUnit tests.
License
MIT