PHPackages                             wcealliance/php-sdk - 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. wcealliance/php-sdk

ActiveLibrary[API Development](/categories/api)

wcealliance/php-sdk
===================

WCEA API PHP SDK

0141PHP

Since Mar 14Pushed 3y ago3 watchersCompare

[ Source](https://github.com/wcealliance/php-sdk)[ Packagist](https://packagist.org/packages/wcealliance/php-sdk)[ RSS](/packages/wcealliance-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WCEA API SDK for PHP
====================

[](#wcea-api-sdk-for-php)

[![Build Status](https://camo.githubusercontent.com/784ef9e0947739eb73f0719d71655d05c9f9a13028a1d1386539cd174aa38711/68747470733a2f2f7472617669732d63692e6f72672f776365616c6c69616e63652f7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wcealliance/php-sdk)

Communicate with the WCEA REST API using PHP

### Install with Composer

[](#install-with-composer)

If you're using [Composer](https://github.com/composer/composer) to manage dependencies, you can add the WCEA SDK with it.

```
{
  "require" : {
    "wcealliance/php-sdk": "dev-master"
  },
  "minimum-stability": "dev"
}
```

### Install source from GitHub

[](#install-source-from-github)

The WCEA SDK requires [Unirest](https://github.com/Mashape/unirest-php) as a dependency. It also requires PHP `v5.3+` and `cURL` extensions for PHP. Download the PHP library from Github, and require in your script like so:

To install the source code:

```
$ git clone git@github.com:wcealliance/php-sdk.git
```

And include it in your scripts:

```
// first include Unirest
require_once '/path/to/unirest-php/lib/Unirest.php';
// then include this
require_once '/path/to/php-sdk/lib/WCEAAPI.php';
```

\##Usage The main requirements for running this SDK are `api_key` and `api_secret`. Please make sure you have them before you proceed any further.

The class can be configured in multiple ways, by sending in a configuration array during class instantiation:

```
// create a new instance
$config_array = array(
  "api_endpoint"   => "http://wceaapi.org",
  "api_key"        => 'YOUR_API_KEY',
  "api_secret"     => 'YOUR_API_SECRET',
  "api_version"    => '1.1'
);
$api = new WCEAAPI($config_array);
```

Or by using a more OOP approach:

```
$api = new WCEAAPI();
$api->setKey('YOUR_API_KEY')
  ->setSecret('YOUR_API_SECRET')
  ->setConfig('api_version', '1.1');
```

Configuration parameters other than `api_key` and `api_secret` have setter and getter methods:

```
// set a config param
$api->setConfig('api_version', '1.1');
// get a config param
$version = $api->getConfig('api_version');
```

**Please Note:** By default, the `api_endpoint` parameter is set to the live URL, to use sandbox mode, please use the sandbox url `http://sandbox.wceaapi.org`.

### Making REST calls to API resources

[](#making-rest-calls-to-api-resources)

Please see the [WCEA API docs](http://docs.wceaapi.org/) for a list of available API resource endpoints. The class uses `__call()` magic method to work out which resource you are calling.

For example:

```
// make a GET request to /user/user@email.com
$user = $api->getUser('user@email.com');
// make a POST request to /user
$user = $api->addUser(array('post_params'));
// make a PUT request to /user/user@email.com
$api->editUser('user@email.com', array('post_params'));
// make a DELETE request to /user/user@email.com
$api->deleteUser('user@email.com');
```

Calling sub-resources follow a similar `camelCased` pattern, for example:

```
// make a GET request to /user/user@email.com/trainingProfile/
$training_profile = $api->getUserTrainingProfile('user@email.com');
```

In simple terms:

- `getXXX()` maps to `GET` requests
- `addXXX()` maps to `POST` requests
- `editXXX()` maps to `PUT` requests
- `deleteXXX()` maps to `DELETE` requests

### Output data &amp; Error handling

[](#output-data--error-handling)

All data from the SDK are in plain PHP arrays. If a method call fails, the output is `false`.

If you encounter the result of a query returning `false`, the error that occured can be obtained from the `getError()` method.

A very simple error resilient code snippet follows:

```
$user = $api->getUser('user@email.com');
if ($user == false) {
  $error = $api->getError();
  if($error){
    throw new Exception($error['errorCode'] . $error['userMessage']);
  }
} else {
  //loop through the returned data
  //and do something with it
}
```

When calling `PUT` and `POST` endpoints (`addXXXX()` and `editXXXX()`), if the payload contains invalid data, data validation messages appear in the form of an array inside the error object:

```
array(
  'errorCode'   => '400',
  'userMessage' => 'Bad Request',
  'devMessage'  => array(
      'email'   => 'Invalid email address'
  )
)
```

#### Response Metadata

[](#response-metadata)

In addition to the special getter `getError()`, there is also another getter method for metadata. `getMetadata()` returns an array containing all the metadata that was sent with the response.

Metadata usually contains the response status, offset/limit values and the total number of records returned. It also contains HATEOAS links which can be leveraged for paginating long lists.

To obtain HATEOAS links only, another special getter `getLinks()` can be used. It returns just the HATEOAS links from a response.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 98.9% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/722e904eb637d556bf81c09e22090cd1e088a5bf5d3cb23c91f4bf3afe0b342c?d=identicon)[wcealliance](/maintainers/wcealliance)

---

Top Contributors

[![ekhaled](https://avatars.githubusercontent.com/u/198751?v=4)](https://github.com/ekhaled "ekhaled (93 commits)")[![verified](https://avatars.githubusercontent.com/u/2069842?v=4)](https://github.com/verified "verified (1 commits)")

### Embed Badge

![Health badge](/badges/wcealliance-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/wcealliance-php-sdk/health.svg)](https://phpackages.com/packages/wcealliance-php-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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