Hi all,
I'm relatively new to working with the Slide Share API. I am
attempting to write a script that will upload a file (the file name
will eventually be provided by a SQL query but it's hard coded at the
moment) to SlideShare but I'm constantly getting the "Slideshow file
is not a source object" error.
It could be (sure it is) a really obvious error with the code; or it
could be something I'm not even considering.
When it comes to providing the filename I have tried running the
script from the directory with the file, using full file name (eg. /
home/user/htdocs/website/filelocation/powerpoint.ppt) and even URL's
but can't seem to get it to work. Each time I get the error 6:
I have included the code I'm using below.
Any suggestions or just a puch in the right direction would be most
welcomed.
Cheers, Jamie.
<?php
// -------------------------------------------------------
// SlideShareCurlUpload.php
// Upload file to
slideshare.net
// -------------------------------------------------------
// Edit User Details
// User API Keys
$api_key = 'xxx';
$sharedsecret = 'zzz';
// Account Information
$username = 'username';
$password = 'password';
// URL for form to be submitted
$url = '
http://www.slideshare.net/api/1/upload_slideshow';
//////////////////////////////////////////////////////////////////////
// Set values needed by CURL to submit to API form
// Set UNIX timestamp variable
$ts = time();
// Concatenate $ts & $sharedsecret
$sha_hash = $ts.$sharedsecret;
// Create SHA1 hash of concatenated variables
$hash = sha1($sha_hash);
// For now - will come from DB
$SlideDetails['filename'] = '11958674511194251558.ppt';
$SlideDetails['title'] = 'test title';
// CURL Paramaters
$params = 'api_key='.$api_key.'&sharedsecret='.
$sharedsecret.'&username='.$username.'&password='.$password.'&ts='.
$ts.'&hash='.$hash.'&slideshow_title='.$SlideDetails
['title'].'&slideshow_srcfile='.$SlideDetails['filename'];
$user_agent = 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)';
$ch = curl_init();
// Do the CURL
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
// For Debugging
echo $params.'<br />';
echo 'Results:'.$result;
?>