Oahu PHP client
Installation
If you are using composer, just add oahu/oahu this to your composer.json file :, (*1)
{
"name" : "my/awesome-oahu-app",
"version" : "0.1.0",
"require" : {
"oahu/oahu": "dev-master"
}
}
Usage
Configuration
<?php
set_include_path(dirname(__FILE__) . ":");
require('vendor/autoload.php');
$config = array(
'oahu' => array(
"host" => "api.example.com",
"clientId" => 'OAHU_CLIENT_ID',
"appId" => 'OAHU_APP_ID',
"appSecret" => 'OAHU_APP_SECRET')
)
);
$oahu = new Oahu_Client($config);
Using caching (with memcached)
API (GET) responses will be cached in Memcached if caching is enabled., (*2)
<?php
set_include_path(dirname(__FILE__) . ":");
require('vendor/autoload.php');
$config = array(
'oahu' => array(
"host" => "api.example.com",
"clientId" => 'OAHU_CLIENT_ID',
"appId" => 'OAHU_APP_ID',
"appSecret" => 'OAHU_APP_SECRET'),
"cache" => "true",
"cacheHost" => "127.0.0.1",
"cachePort" => 11211,
"cacheExpiration" => 120 // in seconds
)
);
$oahu = new Oahu_Client($config);
Making API Calls
get, put, post methods are directly available on your instance of Oahu_Client., (*3)
Examples using the API directly
Getting the list of Projects
<?php
$oahu->get('projects');
<?php
// where ':project_id' is a valid project_id
$oahu->get('projects/:project_id/apps');
<?php
// where ':project_id' is a valid project_id
$oahu->get('projects/:project_id/pub_accounts');
<?php
$oahu->get('projects', array('limit' => 10, 'page' => 2))
Getting the infos on a User Account by its id
$accountInfos = $oahu->getAccount($accountId);
Getting the current User Account if connected via Oahu connect
$accountInfos = $oahu->getCurrentAccount();
APIs
Method Helpers
listProjects($params=array())
Returns a list of Projects for the current Client, (*4)
getProject($projectId)
Returns a Project's infos, (*5)
createProject($projectType, $projectData)
Creates a new Project, (*6)
updateProject($projectId, $projectData)
Update a Project's infos, (*7)
updateProjectPoster($projectId, $imageId)
Set the Project's Poster (default image), (*8)
updateProjectTrailer($projectId, $videoId)
Sets the Project's Trailer (default video), (*9)
getProjectResources($projectId, $params)
Get all Projects resources (Image, Video, ImageList, VideoList), (*10)
getProjectPhotos($projectId, $params)
Get all Project's Image resources, (*11)
getProjectVideos($projectId, $params)
Get all Project's Video resources, (*12)
listProjectPubAccounts($projectId)
Get all Project's PubAccounts (Facebook pages, Twitter accounts), (*13)
createProjectResource($projectId, $resourceType, $resourceData)
Create a new Resource (Image, Video, ImageList, VideoList), (*14)
updateProjectResource($projectId, $resourceId, $resourceData)
Update a single Resource, (*15)
createProjectImageList($projectId, $resourceData)
Helper to create an ImageList, (*16)
createProjectVideoList($projectId, $resourceData)
Helper to create an VideoList, (*17)