imagerelay / imagerelay-php
The Image Relay PHP Library makes it easy for developers to leverage the Image Relay API in their applications.
Requires
- php: >=5.3.3
- ext-curl: *
- guzzle/guzzle: ~3.3
Requires (Dev)
- phpunit/phpunit: 4.7.*
README
If you would like to contribute to the project please fork the repo and create a pull request with your work. Documentation will be updated as end points are added.
Installation
We recommend using composer to manage dependencies and installation of the Image Relay API PHP library. If you are unfamiliar with composer you can read about installation into your application here - Composer Install How To
Run the following command from your console
$ php composer.phar require imagerelay/imagerelay-php
Usage
To use the library you only need to have an Image Relay account with proper permissions to complete the API actions. You will need to require once the vender/autoload.php file provided by composer.
Authorization with username and password
Don't forget to change imagerelay_url
to use your own subdomain or custom url.
<?php require_once 'vendor/autoload.php'; $client = ImageRelay\ImageRelayClient::factory(array( 'imagerelay_url' => 'subdomain.imagerelay.com', 'auth' => 'http', 'username' => 'username', 'password' => 'password', 'app_name' => 'Sample APP', 'app_contact' => 'http://www.sampleapp.com', )); ?>
Authorization with oAuth
When authorizing with oauth you will need to use one of the many existing libraries available to retrieve your oauth access token. The Image Relay API adheres to oauth standars for authentication.
Don't forget to change imagerelay_url
to use your own subdomain or custom url.
<?php require_once 'vendor/autoload.php'; $client = ImageRelay\ImageRelayClient::factory(array( 'imagerelay_url' => 'subdomain.imagerelay.com', 'auth' => 'oauth', 'token' => '08dfsafd8asdf8asdf90as8df90df8', 'app_name' => 'Sample APP', 'app_contact' => 'http://www.sampleapp.com', )); ?>
Files
Get Files from Folder
$response = $client->getFiles( array( 'folder_id' => 8363117, 'page' => 2, ));
Get File
$response = $client->getFile( array( 'id' => 8363117, ));
Upload File from URL
$response = $client->uploadFileFromURL( array( 'filename' => 'test.jpg', 'folder_id' => 285356, 'file_type_id' => 1464, 'terms' => array( 'term_id' => '145', 'value' => 'Test Value', ), 'url' => 'https://upload.wikimedia.org/wikipedia/commons/5/55/Atelopus_zeteki1.jpg' ));
Folders
Get Folders
Top Level Folders
$response = $client->getFolders('page' => 1);
Children of Parent Folder
$response = $client->getChildFolders( array( 'folder_id' => 191678, 'page' => 1 ));
Root Folder
$response = $client->getRootFolder();
Get Folder
$response = $client->getFolder( array( 'folder_id' => 191678, ));
Create Folder
$response = $client->createFolder( array( 'folder_id' => 191678, 'name' => 'Testing Folder Create', ));
Update Folder
$response = $client->updateFolder( array( 'folder_id' => 290503, 'name' => 'New Folder Create', ));
File Types
Get File Types
$response = $client->getFileTypes();
Get File Type
$response = $client->getFileType( array( 'id' => 290503, ));
Folder Links
Get Folder Links
$response = $client->getFolderLinks( array( 'page' => 2, ));
Get Folder Link
$response = $client->getFolderLink( array( 'id' => 290503, ));
Create Folder Link
$response = $client->createFolderLink( array( 'folder_id' => 290503, 'allows_download' => true, 'expires_on' => '2015-07-15', 'show_tracking' => true, 'purpose' => 'Download for spring catalog images', ));
Delete Folder Link
$response = $client->deleteFolderLink( array( 'id' => 290503, ));
Invited Users
Image Relay API: Invited Users
Get Invited Users
$response = $client->getInvitedUsers( array( 'page' => 2, ));
Get Invited User
$response = $client->getInvitedUser( array( 'id' => 290503, ));
Invite New User
$response = $client->inviteNewUser( array( 'first_name' => 'First Name', 'last_name' => 'Last Name', 'email' => 'example@imagerelay.com', 'company' => 'Image Relay', 'permission_id' => 167, ));
Delete Invited User
$response = $client->deleteInvitedUser( array( 'id' => 290503, ));
Permissions
Get Permissions
$response = $client->getPermissions( array( 'page' => 2, ));
Get Permission
$response = $client->getPermission( array( 'id' => 290503, ));
Quick Links
Get Quick Links
$response = $client->getQuickLinks( array( 'page' => 2, ));
Get Quick Link
$response = $client->getQuickLink( array( 'id' => 290503, ));
Create Quick Link
$response = $client->createQuickLink( array( 'asset_id' => 290503, 'purpose' => 'Download for spring catalog images', ));
Delete Quick Link
$response = $client->deleteQuickLink( array( 'id' => 290503, ));
Upload Links
Get Upload Links
$response = $client->getUploadLinks( array( 'page' => 2, ));
Get Upload Link
$response = $client->getUploadLink( array( 'id' => 290503, ));
Create Upload Link
$response = $client->createUploadLink( array( 'folder_id' => 290503, 'purpose' => 'Upload location for spring catalog images', ));
Delete Upload Link
$response = $client->deleteUploadLink( array( 'id' => 290503, ));
Users
Get Users
$response = $client->getUsers( array( 'page' => 2, ));
Get User
$response = $client->getUser( array( 'id' => 290503, ));
Webhooks
Get Webhooks
$response = $client->getWebhooks();
Get Webhook
$response = $client->getWebhook( array( 'id' => 290503, ));
Create Webhook
$response = $client->createWebhook( array( 'resource' => 'file', 'action' => 'created', 'url' => 'https://www.example.com' ));
Delete Upload Link
$response = $client->deleteWebhook( array( 'id' => 290503, ));
Supported Webhooks
$response = $client->getSupportedWebhooks();
KEYWORDING
Keyword Sets
Get Keyword Sets
$response = $client->getKeywordSets( array( 'page' => 2, ));
Get KeywordSet
$response = $client->getKeywordSet( array( 'id' => 290503, ));
Create KeywordSet
$response = $client->createKeywordSet( array( 'name' => 'Sample Keyword Set name', ));
Update KeywordSet
$response = $client->updateKeywordSet( array( 'id' = > 244244, 'name' => 'Sample Keyword Set name', ));
Delete Keyword Set
$response = $client->deleteKeywordSet( array( 'id' => 290503, ));
Keywords
Get Keywords
$response = $client->getKeywords( array( 'keyword_set_id' => 2522, ));
Get Keyword
$response = $client->getKeyword( array( 'keyword_set_id' => 290503, 'keyword_id' => 22323, ));
Create Keyword
$response = $client->createKeyword( array( 'keyword_set_id' => 22422, 'name' => 'Sample Keyword Set name', ));
Update Keyword
$response = $client->updateKeyword( array( 'keyword_set_id' => 32454, 'keyword_id' => 23224, 'name' => 'Sample Keyword Set name', ));
Delete Keyword
$response = $client->deleteKeyword( array( 'keyword_set_id' => 290503, 'keyword_id' => 21424, ));
Uploads
createUploadJob
$uploadJob = $client->createUploadJob( array( 'folder_id' => 291692, 'file_type_id' => 1464, 'files' => array ( array ( 'name' => 'two_frogs.jpg', 'size' => filesize($_SERVER['DOCUMENT_ROOT'].'/two_frogs.jpg') ) ), 'terms' => array ( array ( 'term_id' => '5802', 'value' => 'Testing 123' ) ), ));
createFileChunk
$upload = $client->createFileChunk( array( 'upload_job_id' => $uploadJob['id'], 'file_id' => $uploadJob['files'][0]['id'], 'chunk_id' => 1, 'mimeType' => 'application/octet-stream', 'data' => file_get_contents($_SERVER['DOCUMENT_ROOT'].'/two_frogs.jpg'), ));