PHPackages                             gozfly/gozfly-api-php-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. gozfly/gozfly-api-php-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

gozfly/gozfly-api-php-client
============================

Gozfly API PHP SDK with OAuth 2.0 &amp; CSRF support. Can be used for social sign in or sharing on Gozfly. Examples. Documentation.

1.0(8y ago)04MITPHPPHP &gt;=5.6

Since Dec 20Pushed 8y agoCompare

[ Source](https://github.com/gozfly/gozfly-api-php-client)[ Packagist](https://packagist.org/packages/gozfly/gozfly-api-php-client)[ Docs](https://www.github.com/gozfly/gozfly-api-php-client)[ RSS](/packages/gozfly-gozfly-api-php-client/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Gozfly API Client with OAuth 2 authorization written on PHP
===========================================================

[](#gozfly-api-client-with-oauth-2-authorization-written-on-php)

[![Build Status](https://camo.githubusercontent.com/337c5647081981d29127bd8fbbf6cd860b6b1e4ff9b0a450c98df4dc5ff945f8/68747470733a2f2f7472617669732d63692e6f72672f676f7a666c792f676f7a666c792d6170692d7068702d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gozfly/gozfly-api-php-client) [![Code Climate](https://camo.githubusercontent.com/2bdd6a7bc1e998693ccd44b453359eb0bfa86c0595277d7d8aafea853b107349/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f676f7a666c792f676f7a666c792d6170692d7068702d636c69656e742f6261646765732f6770612e737667)](https://codeclimate.com/github/gozfly/gozfly-api-php-client) [![Packagist](https://camo.githubusercontent.com/2085b45260fefab64e4b74705d55f99553b866d6f9a69e89426f31b3a7644a64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f7a666c792f676f7a666c792d6170692d7068702d636c69656e742e737667)](https://packagist.org/packages/gozfly/gozfly-api-php-client) [![GitHub license](https://camo.githubusercontent.com/a6054a55d9a0f3d0af33845943865d2595eb95fb692a6dbe321a476fe46dcdf0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f676f7a666c792f676f7a666c792d6170692d7068702d636c69656e742e737667)](https://www.github.com/gozfly/gozfly-api-php-client/blob/master/LICENSE.md)

See [complete example](examples/) inside [index.php](examples/index.php) to get started.

Installation
------------

[](#installation)

Use composer package manager

```
composer require gozfly/gozfly-api-php-client
```

Or add this package as dependency to `composer.json`.

If you have never used Composer, you should start [here](http://www.phptherightway.com/#composer_and_packagist)and install composer.

Usage
-----

[](#usage)

To start working with Gozfly API, you will need to get application client id and secret.

Go to [Gozfly Developers portal](https://developer.gozfly.com/)and create new application in section My Apps.

#### Bootstrapping autoloader and instantiating a client

[](#bootstrapping-autoloader-and-instantiating-a-client)

```
// ... please, add composer autoloader first
include_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

// import client class
use Gozfly\Client;

// instantiate the Gozfly client
$client = new Client(
    'GOZFLY_APP_CLIENT_ID',
    'GOZFLY_APP_CLIENT_SECRET'
);
```

#### Getting local redirect URL

[](#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:

```
$redirectUrl = $client->getRedirectUrl();
```

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

[](#setting-local-redirect-url)

Set a custom redirect url use:

```
$client->setRedirectUrl('http://your.domain.tld/path/to/script/');
```

#### Getting Gozfly redirect URL

[](#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:

```
use Gozfly\Scope;

// define scope
$scopes = [
  Scope::READ_BASIC_PROFILE,
  Scope::READ_EMAIL_ADDRESS,
  Scope::MANAGE_COMPANY,
  Scope::SHARING,
];
$loginUrl = $client->getLoginUrl($scopes); // get url on Gozfly to start linking
```

Now you can take user to Gozfly. You can use link or rely on Location HTTP header.

#### Getting Access Token

[](#getting-access-token)

To get access token use (don't forget to set redirect url)

```
$accessToken = $client->getAccessToken($_GET['code']);
```

This method returns object of `Gozfly\AccessToken` class. You can store this token in the file like this:

```
file_put_contents('token.json', json_encode($accessToken));
```

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

[](#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.

```
use Gozfly\AccessToken;
use Gozfly\Client;

// instantiate the Gozfly client
$client = new Client(
    'GOZFLY_APP_CLIENT_ID',
    'GOZFLY_APP_CLIENT_SECRET'
);

// load token from the file
$tokenString = file_get_contents('token.json');
$tokenData = json_decode($tokenString, true);
// instantiate access token object from stored data
$accessToken = new AccessToken($tokenData['token'], $tokenData['expiresAt']);

// set token for client
$client->setAccessToken($accessToken);
```

#### Performing API calls

[](#performing-api-calls)

All API calls can be called through simple method:

```
$profile = $client->api(
    'ENDPOINT',
    ['parameter name' => 'its value here'],
    'HTTP method like GET for example'
);
```

There are two helper methods:

```
// get method
$client->get('ENDPOINT', ['param' => 'value']);

//post
$client->post('ENDPOINT', ['param' => 'value']);
```

#### Examples

[](#examples)

Perform api call to get profile information

```
$profile = $client->get(
    'people/~:(id,email-address,first-name,last-name)'
);
print_r($profile);
```

List companies where you are an admin

```
$profile = $client->get(
    'companies',
    ['is-company-admin' => true]
);
print_r($profile);
```

Share content on a personal profile

```
$share = $client->post(
    'people/~/shares',
    [
        'comment' => 'Checkout this amazing PHP SDK for Gozfly!',
        'content' => [
            'title' => 'PHP Client for Gozfly API',
            'description' => 'OAuth 2 flow, composer Package',
            'submitted-url' => 'https://www.github.com/gozfly/gozfly-api-php-client',
            'submitted-image-url' => 'https://www.github.com/fluidicon.png',
        ],
        'visibility' => [
            'code' => 'anyone'
        ]
    ]
);
```

Share content on a Gozfly business page

```
// set sandboxed company page to work with
// you can check updates at
// https://www.gozfly.com/company/devtestco
$companyId = '2414183';

$share = $client->post(
    'companies/' . $companyId . '/shares',
    [
        'comment' => 'Checkout this amazing PHP SDK for Gozfly!',
        'content' => [
            'title' => 'PHP Client for Gozfly API',
            'description' => 'OAuth 2 flow, composer Package',
            'submitted-url' => 'https://www.github.com/gozfly/gozfly-api-php-client',
            'submitted-image-url' => 'https://www.github.com/fluidicon.png',
        ],
        'visibility' => [
            'code' => 'anyone'
        ]
    ]
);
```

Setup custom API request headers

```
$client->setDefaultApiHeaders([
  'Content-Type' => 'application/json',
  'x-li-format' => 'json',
  'x-li-src' => 'msdk' // set a src header to "msdk" to mimic a mobile SDK
]);
```

Change default API root

```
$client->setApiRoot('https://api.gozfly.com/v2/');
```

Contributing
------------

[](#contributing)

Please, open PR with your changes linked to an GitHub issue. You code must follow [PSR](http://www.php-fig.org/psr/) standards and have PHPUnit tests.

License
-------

[](#license)

[MIT](LICENSE.md)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3113d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34724526?v=4)[GOZFLY, LLC](/maintainers/gozfly)[@gozfly](https://github.com/gozfly)

---

Tags

apiclientrestauthAuthenticationwrapperoauthoauth2authorizationplatformsocialoauth2-clientintegrationsocial networklinked inoauth2-authenticationgozflygozfly-clientgozfly-apigozfly-signingozfly-sdkgozfly-logingozfly.comphp-gozfly

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gozfly-gozfly-api-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/gozfly-gozfly-api-php-client/health.svg)](https://phpackages.com/packages/gozfly-gozfly-api-php-client)
```

###  Alternatives

[zoonman/linkedin-api-php-client

LinkedIn API PHP SDK with OAuth 2.0 &amp; CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.

128716.7k](/packages/zoonman-linkedin-api-php-client)[ezralazuardy/heimdall

Painless OAuth 2.0 Server for CodeIgniter 4

454.2k](/packages/ezralazuardy-heimdall)[chillerlan/php-oauth

A fully transparent, framework agnostic PSR-18 OAuth client.

4111.4k2](/packages/chillerlan-php-oauth)[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

1524.5k1](/packages/chervand-yii2-oauth2-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
