Skip to content

Instantly share code, notes, and snippets.

@techslides
Created November 4, 2014 22:20
Show Gist options
  • Save techslides/2479803c6e8cbe18b86b to your computer and use it in GitHub Desktop.
Save techslides/2479803c6e8cbe18b86b to your computer and use it in GitHub Desktop.
Slide Upload with SlideShare API and PHP cURL
<?php
//user provided settings
$apikey = 'API-KEY';
$secret = 'SECRET';
$username = 'USERNAME';
$password = 'PASSWORD';
$title = "YOUR-TITLE";
$file = rawurlencode('URL-TO-FILE');
$public = "Y";
$ts = time(); //unix timestamp
$hash = sha1($secret.$ts); //SHA1 (sharedsecret + timestamp)
$postdata = 'username='.$username.'&password='.$password.'&upload_url='.$file.'&slideshow_title='.$title.'&make_src_public='.$public.'&api_key='.$apikey.'&ts='.$ts.'&hash='.$hash;
//cURL POST call with SSL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.slideshare.net/api/2/upload_slideshow");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
//execute
$output = curl_exec($ch);
if ($output === FALSE) {
echo "cURL Error: " . curl_error($ch);
} else {
var_dump($output);
}
curl_close($ch);
?>
@techslides
Copy link
Author

@DhruveshTripathi
Copy link

Do we need to enter our password in hashed code?

Facing an Error : string(145) " Failed User authentication "

@FraGoTe
Copy link

FraGoTe commented Sep 4, 2017

<?xml version="1.0" encoding="UTF-8"?>
<SlideShareServiceError>
  <Message ID="25">API uploads are no longer supported</Message>
</SlideShareServiceError>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment