Example #1
0
 /**
  * Uploads the specified Slide show the the server
  *
  * @param Zend_Service_SlideShare_SlideShow $ss The slide show object representing the slide show to upload
  * @param boolean $make_src_public Determines if the the slide show's source file is public or not upon upload
  * @return Zend_Service_SlideShare_SlideShow The passed Slide show object, with the new assigned ID provided
  */
 public function uploadSlideShow(Zend_Service_SlideShare_SlideShow $ss, $make_src_public = true)
 {
     $timestamp = time();
     $params = array('api_key' => $this->getApiKey(), 'ts' => $timestamp, 'hash' => sha1($this->getSharedSecret() . $timestamp), 'username' => $this->getUserName(), 'password' => $this->getPassword(), 'slideshow_title' => $ss->getTitle());
     $description = $ss->getDescription();
     $tags = $ss->getTags();
     $filename = $ss->getFilename();
     if (!file_exists($filename) || !is_readable($filename)) {
         require_once 'Zend/Service/SlideShare/Exception.php';
         throw new Zend_Service_SlideShare_Exception("Specified Slideshow for upload not found or unreadable");
     }
     if (!empty($description)) {
         $params['slideshow_description'] = $description;
     } else {
         $params['slideshow_description'] = "";
     }
     if (!empty($tags)) {
         $tmp = array();
         foreach ($tags as $tag) {
             $tmp[] = "\"{$tag}\"";
         }
         $params['slideshow_tags'] = implode(' ', $tmp);
     } else {
         $params['slideshow_tags'] = "";
     }
     $client = $this->getHttpClient();
     $client->setUri(self::SERVICE_UPLOAD_URI);
     $client->setParameterPost($params);
     $client->setFileUpload($filename, "slideshow_srcfile");
     require_once 'Zend/Http/Client/Exception.php';
     try {
         $response = $client->request('POST');
     } catch (Zend_Http_Client_Exception $e) {
         require_once 'Zend/Service/SlideShare/Exception.php';
         throw new Zend_Service_SlideShare_Exception("Service Request Failed: {$e->getMessage()}", 0, $e);
     }
     $sxe = simplexml_load_string($response->getBody());
     if ($sxe->getName() == "SlideShareServiceError") {
         $message = (string) $sxe->Message[0];
         list($code, $error_str) = explode(':', $message);
         require_once 'Zend/Service/SlideShare/Exception.php';
         throw new Zend_Service_SlideShare_Exception(trim($error_str), $code);
     }
     if (!$sxe->getName() == "SlideShowUploaded") {
         require_once 'Zend/Service/SlideShare/Exception.php';
         throw new Zend_Service_SlideShare_Exception("Unknown XML Respons Received");
     }
     $ss->setId((int) (string) $sxe->SlideShowID);
     return $ss;
 }
 public function testSlideShowObj()
 {
     $ss = new Zend_Service_SlideShare_SlideShow();
     $ss->setDescription("Foo");
     $ss->setEmbedCode("Bar");
     $ss->setFilename("Baz");
     $ss->setId(123);
     $ss->setLocation("Somewhere");
     $ss->setNumViews(4432);
     $ss->setPermaLink("nowhere");
     $ss->setStatus(124);
     $ss->setStatusDescription("Boo");
     $ss->setTags(array('bar', 'baz'));
     $ss->addTag('fon');
     $ss->setThumbnailUrl('asdf');
     $ss->setTitle('title');
     $ss->setTranscript('none');
     $this->assertEquals($ss->getDescription(), "Foo");
     $this->assertEquals($ss->getEmbedCode(), "Bar");
     $this->assertEquals($ss->getFilename(), "Baz");
     $this->assertEquals($ss->getId(), 123);
     $this->assertEquals($ss->getLocation(), "Somewhere");
     $this->assertEquals($ss->getNumViews(), 4432);
     $this->assertEquals($ss->getPermaLink(), "nowhere");
     $this->assertEquals($ss->getStatus(), 124);
     $this->assertEquals($ss->getStatusDescription(), "Boo");
     $this->assertEquals($ss->getTags(), array('bar', 'baz', 'fon'));
     $this->assertEquals($ss->getThumbnailUrl(), "asdf");
     $this->assertEquals($ss->getTitle(), "title");
     $this->assertEquals($ss->getTranscript(), "none");
 }