For all the API calls, first create an object of the SDK class so that you can access the SDK functions.
To create an object of the SDK class, pass the following information to the SDK constructor:
clientKey
- obtained when you created an application in Key ManagementclientSecret
- obtained when you created an application in Key ManagementcallbackUrl
- HTTP callback address where the user can access the application. Your app must specify it exactly as you have entered it in Key Management as it is case sensitive.
$sdk = new Thingspace\Cloud\Sdk(clientKey,clientSecret,callbackUrl);
The PHP SDK allows you to access Personal Cloud Storage account holder’s data to retrieve, create, edit, modify, and delete playlists. Supported types of playlists include image, music, video, and image-video playlists. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with playlists.
getPlaylists
retrieves a user specific list of playlists.
Required Parameters
type
– The type of the playlist, such as:start
- Starting point for partial responses for folder requests. Default is 1.count
- Maximum items to include in a paginated response for folder requests. Required, if start
is specified.sort
- Specifies sort order for the response. Syntax is {field}+{asc|desc}
. Valid values for field
are:Code Sample
try {
$response = $sdk->getPlaylists($type, $start, $count, $sort);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
[{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}]
getPlaylistItems
retrieves detailed information on the items in a specified playlist.
Required Parameters
playlistUid
– Unique ID which identifies a playlist.start
- Starting point for partial responses for folder requests. Default is 1.count
- Maximum items to include in a paginated response for folder requests. Required, if start is specified.sort
- Specifies the sort order of the response items. Syntax is :{field}+{asc|desc}
. Valid values for field
are:Code Sample
try {
$response = $sdk->getPlaylistItems($playlistUid);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
[{
"filename": "string",
"path": "string",
"mimeType": "string",
"size": 0,
"versionCreated": "string",
"fileAttribute": {},
"contentToken": "string",
"checksum": "string",
"contentAccessible": true,
"extension": "string",
"tags": {},
"uri": "string"
}]
getPlaylistDefinition
retrieves the definition of a specified playlist.
Required Parameters
playlistUid
– Unique id that identifies a playlist.Code Sample
try {
$response = $sdk->getPlaylistDefinition($playlistUid);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
getPlaylistItemContent
retrieves the content of the playlist at the specified path.
Required Parameters
playlistUid
– Unique ID which identifies a playlist.itemUid
– Unique ID which identifies an item in a playlist.Code Sample
try {
$response = $sdk->getPlaylistItemContent($playlistUid,$itemUid);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
createPlaylist
creates a playlist, with or without items.
Required Parameters
name
– The name of a playlistpaths
– An array of paths to items in a playlisttype
– The type of the playlist, such as:Parameter request format:
{
"name": "string",
"paths": [
"string"
],
"type": "string"
}
Code Sample
try {
$paths = explode(',',$paths);
$response = $sdk->createPlaylist($name, $paths, $type);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
addPlaylistItems
allows a client to add single or multiple items in a playlist.
Required Parameters
playlistUid
– Unique ID which identifies a playlist.add
– An array of paths to items in a playlistParameter request format:
{
"add": [
"string"
]
}
Code Sample
try {
$playlistItems = explode(',',$playlistItems);
$response = $sdk->addPlaylistItems($playlistuid, $playlistItems);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
{
"paths": ["string"]
}
updatePlaylist
allows a client to update a playlist’s name.
Required Parameters
playlistUid
– Unique ID which identifies a playlistname
– Name of the playlisttype
– The type of the playlist,, such asParameter request format:
{
"name": "string",
"type": "string"
}
Code Sample
try {
$response = $sdk->updatePlaylist($playlistuid,$name,$type);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
updatePlaylistDefinition
allows a client to update a playlist by sending a new playlistDefinition
model.
Required Parameters
playlistUid
– Unique id related to a specific playlist.name
– Name of the playlist.paths
– An array of paths to items.type
– The type of the playlist, such as:Parameter request format:
{
"name": "string",
"paths": [
"string"
],
"type": "string"
}
Code Sample
try {
$paths = explode(',',$paths);
$response = $sdk->updatePlaylistDefinition($playlistuid,$name,$paths,$type);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Example Return Response
{
"uid": "string",
"name": "string",
"type": "string",
"mimeTypeRegex": "string",
"paths": ["string"],
"creationDate": "string",
"lastModifiedDate": "string",
"uri": "string",
"shareAssociation": [{
"uid": "string",
"visibility": "string",
"name": "string",
"type": "string"
}]
}
deletePlaylist
deletes a specified playlist.
Required Parameters
playlistUid
– Unique ID of the specified playlist.Code Sample
try {
$response = $sdk->deletePlaylist($playlistuid);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
deletePlaylistItem
allows a client to remove a single item from a playlist.
Required Parameters
playlistUid
– Unique ID of the specified playlist.itemUid
– Unique ID of the specified item in a playlist.Code Sample
try {
$response = $sdk->deletePlaylistItem($playlistuid,$itemUid);
$response = json_decode($response->getBody()->getContents(),true);
} catch (Exception $e) {
try
{
return $e->getResponse();
}
finally {
return false;
}
}
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.