Thank you for visiting the Rackspace Community
The The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

Temp URL PHP Example?

I have access to the php-opencloud lib but it doesn't matter to me if I use it for this or not. I've found many examples of generating temp URLs for files stored in a container but all of them seem to be outdated (the most recent I found is from 4 years ago). I've tried them all with no luck. 

This example does exactly what I'm trying to do but apparently the API has changed since it was written. Can anyone correct it for me to run under the current version of php-opencloud, or provide a straight Rackspace API version? Additionally, I'm *slightly* confused as to what the $connection variable is -- $connection = new Rackspace?? I tried that but the whole thing died with "no method" errors out the wazoo..

// connect to Cloud Files
$objstore = $connection->ObjectStore('cloudFiles', 'DFW');

// Set a secret
define('TEMP_URL_SECRET', 'This is my secret');
$objstore->SetTempUrlSecret(TEMP_URL_SECRET);

// Put the container and file names
$mycontainer = $objstore->Container('CdnContainer');
$object = $mycontainer->DataObject('FOOBAR');

// Create the temp url
$tempurl = $object->TempUrl(TEMP_URL_SECRET, 20, 'GET');

// Print stuff for testing
printf("Filename: %s\n", $object->Name());
printf("CDN URL: %s\n", $object->PublicURL());
printf("TEMP URL: %s\n", $tempurl);


gist.github.com/.../6029442