Having problem with file upload using CURL in SlideShare API.
I am using SlideShare API version 2.0 and trying to upload a PPT file using "upload_slideshow" method. For file upload I am using CURL in PHP. "upload_slideshow" method returns "false" instead of "slideshow id". Don't know what going wrong.
Here is my code:
$key= "my_api_key";
$secret = "my_secret_key";
$user = "my_username";
$password = "my_password";
$title = "This is a test title";
$srcfile = "@path/to/file";
$ts=time();
$hash=sha1($secret.$ts);
$curl_apiurl = "http://www.slideshare.net/api/2/upload_slideshow"."?api_key=$key&ts=$ts&hash=$hash";
$post_params['username'] = urlencode($user);
$post_params['password'] = urlencode($password);
$post_params['slideshow_title'] = urlencode($title);
$post_params['slideshow_srcfile'] = $srcfile;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curl_apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
Please help me.
Here is my code:
$key= "my_api_key";
$secret = "my_secret_key";
$user = "my_username";
$password = "my_password";
$title = "This is a test title";
$srcfile = "@path/to/file";
$ts=time();
$hash=sha1($secret.$ts);
$curl_apiurl = "http://www.slideshare.net/api/2/upload_slideshow"."?api_key=$key&ts=$ts&hash=$hash";
$post_params['username'] = urlencode($user);
$post_params['password'] = urlencode($password);
$post_params['slideshow_title'] = urlencode($title);
$post_params['slideshow_srcfile'] = $srcfile;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curl_apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
Please help me.
2
people have this problem
I have this problem, too!
Tell me when someone solves it.
The more people who report this problem, the more it gets noticed.
The more people who report this problem, the more it gets noticed.
-
Inappropriate?You don't need the curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params); should be enough. I had what you had as well, and was having the same problems you were having, but removed it and it started to work. Hope this helps.
also, you might want to place the api_key, the ts, and the hash in the postfields as well. -
Inappropriate?if(isset($_POST['DataSend']))
{
$title = $_POST['slideshow_title'];
$srcfile = $_POST['slideshow_srcfile'];
if(move_uploaded_file($_FILES["slideshow_srcfile"]["tmp_name"],"upload/" . $_FILES["slideshow_srcfile"]["name"])) {
$ret .= "File Uploaded to our server";
}
else {
$ret .= "Error File not Uploaded to our server";
exit();
}
include_once 'SSUtil.php';
$ts=time();
$secret='some_secret';
$hash=sha1($secret.$ts);
$key='Some_key;
$apiurl='http://www.slideshare.net/api/2/';
$method = 'upload_slideshow';
$location = $apiurl.$method."?api_key=".$key."&ts=".$ts."&hash=".$hash;
$user = "username";
$password = "password";
$target = "upload/" . $_FILES['slideshow_srcfile']['name'];
$srcfile = $target ;
$ret .= "
Source File: " . $srcfile;
$ret .= "
URL Encoded Source File: " . urlencode($srcfile);
$curl_apiurl = $location;
$ch = curl_init();
$post_params['username'] = urlencode($user);
$post_params['password'] = urlencode($password);
$post_params['slideshow_title'] = urlencode($title);
$post_params['slideshow_srcfile'] = @$srcfile;
curl_setopt($ch, CURLOPT_URL, $curl_apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
$ret .= "
Error: ".curl_error($ch);
curl_close($ch);
$ret .= "
The Result is: ".$result;
}
else
{
$str="";
$str=";
$ret .= $str;
}
This is my code and I am getting this error:
6: Slideshow file is not a source object
Can any one help me I am very frusted with this.
Loading Profile...




