PHPackages                             audienceplayer/audienceplayer-api-client-php - 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. [API Development](/categories/api)
4. /
5. audienceplayer/audienceplayer-api-client-php

ActiveLibrary[API Development](/categories/api)

audienceplayer/audienceplayer-api-client-php
============================================

AudiencePlayer API client library for PHP.

v2.0.1(3y ago)1264BSD-2-ClausePHPPHP &gt;=7.1

Since Oct 22Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (20)Used By (0)

AudiencePlayer API client for PHP
=================================

[](#audienceplayer-api-client-for-php)

Introduction
------------

[](#introduction)

This package contains the AudiencePlayer API-client for PHP and facilitates:

- API-integration with your own administration and/or back office.
- Custom frontend application development.

Though not strictly necessary, a pre-existing [AudiencePlayer account](https://www.audienceplayer.com/contact) with issued OAuth2 client credentials is the main use case for which this package is optimised.

Requirements
------------

[](#requirements)

To use the AudiencePlayer API-client for PHP, the following requirements must be observed:

- PHP &gt;= 7.1 (recommended &gt;= 7.3)
- PHP JSON extension
- PHP cURL extension
- Up-to-date OpenSSL (or other SSL/TLS toolkit)

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

[](#installation)

The easiest way to install this package is with [Composer](http://getcomposer.org/doc/00-intro.md):

```
    $ composer require audienceplayer/audienceplayer-api-client-php
```

Alternatively, you can integrate this package by downloading it and including the file `AutoLoader.php`:

```
    require 'src/AudiencePlayer/AudiencePlayerApiClient/AutoLoader.php';
```

Getting started
---------------

[](#getting-started)

### Instantiation

[](#instantiation)

First instantiate the API-client:

```
    $clientId = 'yourOAuthClientId';
    $clientSecret = 'yourOAuthClientSecret';
    $projectId = 123456;
    $apiBaseUrl = 'https://api.example.com';

    # Instantiate with your clientId, clientSecret, projectId and apiBaseUrl
    $apiClient = AudiencePlayerApiClient::init(
        $clientId,
        $clientSecret,
        $projectId,
        $apiBaseUrl
    );
```

Authenticate via the proper mechanism to gain access for a given user (or alternatively as an OAuth2 admin client):

```
    # Pre-existing bearerToken that you may have cached for given user
    $bearerToken = 'eYarTl93Fas3...';
    # User-ID or E-mail address of the user for whom you are validating/creating a token
    $userEmail = 'info@example.com';
    # When validating with only an e-mail address, the user may be auto-registered if non-existent
    $isAutoRegister = true;

    # Compare new token with pre-existing token and update your stored token if necessary
    $newBearerToken = $apiClient->hydrateValidatedOrRenewedBearerTokenForUser(
        $userId,
        $userEmail,
        $userArgs,
        $bearerToken,
        $isAutoRegister
    );
```

### Execute Queries and Mutations

[](#execute-queries-and-mutations)

Example of a GraphQL query operation:

```
    # Example of fetching an article with ID=123, and requesting properties name and type
    $result = $apiClient->query
        ->Article(123)                                              # required argument $id=123
        ->properties(['name', 'type'])                              # explicitly ask for given properties
        ->execute();

    # Example of fetching an articles list
    $result = $apiClient->query
        ->ArticleList()
        ->paginate(25, 0)                                           # with limit 25 and offset 0
        ->arguments(['category_id' => 456])                         # fetched all articles part of category with id 456
        ->properties(['id', 'name', 'metas' => ['key', 'value']])   # explicitly ask for given properties
        ->sort(                                                     # sort results by id in descending order
            'id',
            $apiClient:GRAPHQL_OPERATION_SORT_DIRECTION_DESC
        )
        ->execute();

    # Example of searching for specific articles
    $result = $apiClient->query
        ->ArticleList()
        ->search('foobar')                                          # search for articles with matching metadata
        ->properties(['id', 'name', 'metas{key,value}'])            # explicitly ask for given properties
        ->sort(                                                     # sort results by name in descending order
            'name',
            $apiClient:GRAPHQL_OPERATION_SORT_DIRECTION_ASC
        )
        ->execute();
```

Example of a GraphQL mutation operation:

```
    # Example of updating user details
    $result = $apiClient->mutation
        ->UserDetails()
        ->arguments(['email' => 'info2@example.com'])               # update with given arguments
        ->execute();
```

You can easily process the operation result object with the following helpers:

```
    # Inspect the result
    $result->isSuccessful();                        # result was successfully retrieved and does not contain any errors
    $result->hasErrors();                           # result contains errors
    $result->getErrors();                           # obtain a list of errors

    # Access result properties
    $result->data;                                  # the returned data
    $result->getData();

    # Inspect the last graphql operation, which may be helpful for debugging purposes
    $result->getOperationQuery();                   # the executed raw graphQL query, e.g. "query{UserDetails{id,email}}"
    $result->getOperationVariables();               # the used graphQL variables (if applicable), e.g. "{id:1}"
```

### Custom Queries and Mutations

[](#custom-queries-and-mutations)

You can also execute custom GraphQL queries and mutations. For more information about the GraplhQL syntax, please see [graphql.org](https://graphql.org).

```
    $operation = 'query Article($articleId:Int) {
                  CustomArticleQuery: Article (id:$articleId) {id name}
              }
    ';

    $result = $apiClient->executeRawGraphQLCall(
        Globals::OAUTH_SCOPE_USER,                  # the oauth-scope you wish to address the api with
        $operation,                                 # raw GraphQL operation (query/mutation)
        ['articleId' => 1],                         # variables for the operation (if necessary)
        true,                                       # execute as POST request (false for GET)
        true,                                       # retrieve result as parsed object (false for raw JSON)
        'Article',                                  # operation name
        $bearerToken                                # your stored/saved OAuth bearer token
    );

    $result = $apiClient->executeRawGraphQLCall(
        Globals::OAUTH_SCOPE_USER,                  # The oauth-scope you wish to address the api with
        'query{Article(id:1){id,name}}',            # simple raw GraphQL operation without variables
        [],                                         # the variables for the operation (if necessary)
        true,                                       # execute as POST request (false for GET)
        true,                                       # retrieve result as parsed object (false for raw JSON)
        'Article',                                  # operation name
        $bearerToken                                # your stored/saved OAuth bearer token
    );
```

### Testing

[](#testing)

You can run unit and static tests by executing:

```
    $ composer run test
```

Or run them separately:

```
    $ ./vendor/bin/phpunit
    $ ./vendor/bin/phpstan
```

License
-------

[](#license)

[BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php). Copyright (c) 2020, AudiencePlayer

Support
-------

[](#support)

Contact:

- [www.audienceplayer.com](https://www.audienceplayer.com)
-

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~46 days

Recently: every ~129 days

Total

19

Last Release

1200d ago

Major Versions

v0.3.4 → v1.0.02020-12-03

v1.2.1 → v2.0.02022-11-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6998651?v=4)[AudiencePlayer](/maintainers/audienceplayer)[@AudiencePlayer](https://github.com/AudiencePlayer)

---

Top Contributors

[![plivius](https://avatars.githubusercontent.com/u/1803825?v=4)](https://github.com/plivius "plivius (32 commits)")

---

Tags

apiapi-clientaudienceplayervideoplatformapi clientaudienceplayer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[alaouy/youtube

Laravel PHP Facade/Wrapper for the Youtube Data API v3

8091.3M9](/packages/alaouy-youtube)[madcoda/php-youtube-api

PHP wrapper for the Youtube Data API v3

4451.2M8](/packages/madcoda-php-youtube-api)[smsapi/php-client

SMSAPI API PHP Client

652.1M17](/packages/smsapi-php-client)[crowdin/crowdin-api-client

PHP client library for Crowdin API v2

611.5M5](/packages/crowdin-crowdin-api-client)[ringcentral/ringcentral-php

RingCentral Platform PHP SDK

541.2M5](/packages/ringcentral-ringcentral-php)[inspirum/balikobot

PHP library for Balikobot API

20379.7k4](/packages/inspirum-balikobot)

PHPackages © 2026

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