About Shares

About Shares

Contents

Introduction

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);

Examples

createShare

createShare allows you to create a share.

Request Parameters

  • name - The name of the share.
  • resources - An array of resource request objects.
    • name - Name of the resource.
    • type - Type of the resource:
      • file
      • folder
      • playlist
    • subType - subtype of the resource. It is used to aid playback of the file when viewed in a browser. Can be:
      • image
      • video
      • audio
    • location - Location of the resource. This is a URI value obtained from a fullview, metadata, or playlist response
      • size - Size of the resource. Mandatory in case of a file share only
  • expiresIn - The time to live of the share in seconds. The value 0 signifies the share will never expire. Minimum value is 300. If not provided, defaults to 86400.

Code Sample

try {
	
	$response = $sdk->createShare($name, $rname, $type, $subType, $location, $size, $expiresIn);
	$response = json_decode($response->getBody()->getContents(),true);
	
	} catch (Exception $e) {
		
	 	try
		{
	  	   return $e->getResponse();	
		}
		finally {
		 
		   return $e->getResponse()->getBody()->getContents();
		}
	}

Example Return Response

{
	"links": [{
		"rel": "string",
		"link": "string"
	}],
	"uid": "string",
	"name": "string",
	"owner": {},
	"sharer": {},
	"totalResourceCount": 0,
	"expiresIn": 0,
	"expirationDate": "string",
	"creationDate": "string",
	"lastModifiedDate": "string",
	"inboundLastModifiedDate": "string",
	"publicInviteKey": "string",
	"resources": [{
		"uid": "string",
		"name": "string",
		"type": "string",
		"subType": "string",
		"location": "string",
		"size": 0,
		"resourceId": "string",
		"contentToken": "string",
		"checksum": "string",
		"lastModifiedDate": "string"
		"url": "string"
	}]
}

deleteShare

deleteShare allows you to delete a share.

Request Parameters

  • shareUid - The unique ID of the share.

Code Sample

try {
	$response = $sdk->deleteShare($shareUid);
	$response = json_decode($response->getBody()->getContents(),true);
	
	} catch (Exception $e) {
	 	try
		{
	  	   return $e->getResponse();	
		}
		finally {
		   return false;
		}
	}

getShares

getShares allows you to retrieve a list of shares.

Request Parameters

  • cursor - A cursor used in paginating the response. Cursors are returned in next and prev links in the response body.
  • filter - Filters the returned shares. Currently the value can only be outbound (shared by the user).
  • since - The date and time, expressed in the W3C date and time format, after which messages should be returned.
  • until - The date and time, expressed in the W3C date and time format, up to which messages should be returned.
  • count - Maximum items to include in a paginated response, for share requests.Value must be between 1 and 200. Default is 20

Code Sample

try {
	
	$response = $sdk->getShares($cursor, $filter, $since, $until, $count);
	$response = json_decode($response->getBody()->getContents(),true);
	
	} catch (Exception $e) {

	 	try
		{
	  	   return $e->getResponse();	
		}
		finally {
		   return $e->getResponse()->getBody()->getContents();
		}
	} 

Example Return Response

{
	"count": 0,
	"links": [{
		"rel": "string",
		"link": "string"
	}],
	"share": [{
		"links": [{
			"rel": "string",
			"link": "string"
		}],
		"uid": "string",
		"name": "string",
		"owner": {},
		"sharer": {},
		"totalResourceCount": 0,
		"expiresIn": 0,
		"expirationDate": "string",
		"creationDate": "string",
		"lastModifiedDate": "string",
		"url": "string"
		"inboundLastModifiedDate": "string",
		"publicInviteKey": "string"
	}]
}

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.