About Playlists

About Playlists

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 Management
  • clientSecret - obtained when you created an application in Key Management
  • callbackUrl - 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);

Introduction

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.

Examples

getPlaylists

getPlaylists retrieves a user specific list of playlists.

Required Parameters

  • type – The type of the playlist, such as:
    • image
    • music
    • video
    • image-video
  • 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:
    • name
    • creationDate

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

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:
    • name
    • versionCreated
    • size
    • extension
    • album, artist
    • captureDate
    • compilation
    • contentType
    • creationDate
    • favorite
    • genre
    • height
    • modificationDate
    • priority
    • source
    • tags
    • title
    • timelineDate

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

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

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

createPlaylist creates a playlist, with or without items.

Required Parameters

  • name – The name of a playlist
  • paths – An array of paths to items in a playlist
  • type – The type of the playlist, such as:
    • image
    • music
    • video
    • image-video

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

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 playlist

Parameter 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

updatePlaylist allows a client to update a playlist’s name.

Required Parameters

  • playlistUid – Unique ID which identifies a playlist
  • name – Name of the playlist
  • type – The type of the playlist,, such as
    • image
    • music
    • video
    • image-video

Parameter 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

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:
    • image
    • music
    • video
    • image-video

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

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

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.