Documentation

Zend_Service_SlideShare - Zend_Service

Zend_Service_SlideShare

The Zend_Service_SlideShare component is used to interact with the » slideshare.net web services for hosting slide shows online. With this component, you can embed slide shows which are hosted on this web site within a web site and even upload new slide shows to your account.

Getting Started with Zend_Service_SlideShare

In order to use the Zend_Service_SlideShare component you must first create an account on the slideshare.net servers (more information can be found » here) in order to receive an API key, username, password and shared secret value -- all of which are needed in order to use the Zend_Service_SlideShare component.

Once you have setup an account, you can begin using the Zend_Service_SlideShare component by creating a new instance of the Zend_Service_SlideShare object and providing these values as shown below:

  1. // Create a new instance of the component
  2. $ss = new Zend_Service_SlideShare('APIKEY',
  3.                                   'SHAREDSECRET',
  4.                                   'USERNAME',
  5.                                   'PASSWORD');

The SlideShow object

All slide shows in the Zend_Service_SlideShare component are represented using the Zend_Service_SlideShare_SlideShow object (both when retrieving and uploading new slide shows). For your reference a pseudo-code version of this class is provided below.

  1. class Zend_Service_SlideShare_SlideShow {
  2.  
  3.     /**
  4.      * Retrieves the location of the slide show
  5.      */
  6.     public function getLocation() {
  7.         return $this->_location;
  8.     }
  9.  
  10.     /**
  11.      * Gets the transcript for this slide show
  12.      */
  13.     public function getTranscript() {
  14.         return $this->_transcript;
  15.     }
  16.  
  17.     /**
  18.      * Adds a tag to the slide show
  19.      */
  20.     public function addTag($tag) {
  21.         $this->_tags[] = (string)$tag;
  22.         return $this;
  23.     }
  24.  
  25.     /**
  26.      * Sets the tags for the slide show
  27.      */
  28.     public function setTags(Array $tags) {
  29.         $this->_tags = $tags;
  30.         return $this;
  31.     }
  32.  
  33.     /**
  34.      * Gets all of the tags associated with the slide show
  35.      */
  36.     public function getTags() {
  37.         return $this->_tags;
  38.     }
  39.  
  40.     /**
  41.      * Sets the filename on the local filesystem of the slide show
  42.      * (for uploading a new slide show)
  43.      */
  44.     public function setFilename($file) {
  45.         $this->_slideShowFilename = (string)$file;
  46.         return $this;
  47.     }
  48.  
  49.     /**
  50.      * Retrieves the filename on the local filesystem of the slide show
  51.      * which will be uploaded
  52.      */
  53.     public function getFilename() {
  54.         return $this->_slideShowFilename;
  55.     }
  56.  
  57.     /**
  58.      * Gets the ID for the slide show
  59.      */
  60.     public function getId() {
  61.         return $this->_slideShowId;
  62.     }
  63.  
  64.     /**
  65.      * Retrieves the HTML embed code for the slide show
  66.      */
  67.     public function getEmbedCode() {
  68.         return $this->_embedCode;
  69.     }
  70.  
  71.     /**
  72.      * Retrieves the Thumbnail URi for the slide show
  73.      */
  74.     public function getThumbnailUrl() {
  75.         return $this->_thumbnailUrl;
  76.     }
  77.  
  78.     /**
  79.      * Sets the title for the Slide show
  80.      */
  81.     public function setTitle($title) {
  82.         $this->_title = (string)$title;
  83.         return $this;
  84.     }
  85.  
  86.     /**
  87.      * Retrieves the Slide show title
  88.      */
  89.     public function getTitle() {
  90.         return $this->_title;
  91.     }
  92.  
  93.     /**
  94.      * Sets the description for the Slide show
  95.      */
  96.     public function setDescription($desc) {
  97.         $this->_description = (string)$desc;
  98.         return $this;
  99.     }
  100.  
  101.     /**
  102.      * Gets the description of the slide show
  103.      */
  104.     public function getDescription() {
  105.         return $this->_description;
  106.     }
  107.  
  108.     /**
  109.      * Gets the numeric status of the slide show on the server
  110.      */
  111.     public function getStatus() {
  112.         return $this->_status;
  113.     }
  114.  
  115.     /**
  116.      * Gets the textual description of the status of the slide show on
  117.      * the server
  118.      */
  119.     public function getStatusDescription() {
  120.         return $this->_statusDescription;
  121.     }
  122.  
  123.     /**
  124.      * Gets the permanent link of the slide show
  125.      */
  126.     public function getPermaLink() {
  127.         return $this->_permalink;
  128.     }
  129.  
  130.     /**
  131.      * Gets the number of views the slide show has received
  132.      */
  133.     public function getNumViews() {
  134.         return $this->_numViews;
  135.     }
  136. }

Note: The above pseudo-class only shows those methods which should be used by end-user developers. Other available methods are internal to the component.

When using the Zend_Service_SlideShare component, this data class will be used frequently to browse or add new slide shows to or from the web service.

Retrieving a single slide show

The simplest usage of the Zend_Service_SlideShare component is the retrieval of a single slide show by slide show ID provided by the slideshare.net application and is done by calling the getSlideShow() method of a Zend_Service_SlideShare object and using the resulting Zend_Service_SlideShare_SlideShow object as shown.

  1. // Create a new instance of the component
  2. $ss = new Zend_Service_SlideShare('APIKEY',
  3.                                   'SHAREDSECRET',
  4.                                   'USERNAME',
  5.                                   'PASSWORD');
  6.  
  7. $slideshow = $ss->getSlideShow(123456);
  8.  
  9. print "Slide Show Title: {$slideshow->getTitle()}<br/>\n";
  10. print "Number of views: {$slideshow->getNumViews()}<br/>\n";

Retrieving Groups of Slide Shows

If you do not know the specific ID of a slide show you are interested in retrieving, you can retrieving groups of slide shows by using one of three methods:

  • Slide shows from a specific account

    You can retrieve slide shows from a specific account by using the getSlideShowsByUsername() method and providing the username from which the slide shows should be retrieved

  • Slide shows which contain specific tags

    You can retrieve slide shows which contain one or more specific tags by using the getSlideShowsByTag() method and providing one or more tags which the slide show must have assigned to it in order to be retrieved

  • Slide shows by group

    You can retrieve slide shows which are a member of a specific group using the getSlideShowsByGroup() method and providing the name of the group which the slide show must belong to in order to be retrieved

Each of the above methods of retrieving multiple slide shows a similar approach is used. An example of using each method is shown below:

  1. // Create a new instance of the component
  2. $ss = new Zend_Service_SlideShare('APIKEY',
  3.                                   'SHAREDSECRET',
  4.                                   'USERNAME',
  5.                                   'PASSWORD');
  6.  
  7. $starting_offset = 0;
  8. $limit = 10;
  9.  
  10. // Retrieve the first 10 of each type
  11. $ss_user = $ss->getSlideShowsByUser('username', $starting_offset, $limit);
  12. $ss_tags = $ss->getSlideShowsByTag('zend', $starting_offset, $limit);
  13. $ss_group = $ss->getSlideShowsByGroup('mygroup', $starting_offset, $limit);
  14.  
  15. // Iterate over the slide shows
  16. foreach($ss_user as $slideshow) {
  17.    print "Slide Show Title: {$slideshow->getTitle}<br/>\n";
  18. }

Zend_Service_SlideShare Caching policies

By default, Zend_Service_SlideShare will cache any request against the web service automatically to the filesystem (default path /tmp) for 12 hours. If you desire to change this behavior, you must provide your own Zend_Cache object using the setCacheObject() method as shown:

  1. $frontendOptions = array(
  2.                         'lifetime' => 7200,
  3.                         'automatic_serialization' => true);
  4. $backendOptions  = array(
  5.                         'cache_dir' => '/webtmp/');
  6.  
  7. $cache = Zend_Cache::factory('Core',
  8.                              'File',
  9.                              $frontendOptions,
  10.                              $backendOptions);
  11.  
  12. $ss = new Zend_Service_SlideShare('APIKEY',
  13.                                   'SHAREDSECRET',
  14.                                   'USERNAME',
  15.                                   'PASSWORD');
  16. $ss->setCacheObject($cache);
  17.  
  18. $ss_user = $ss->getSlideShowsByUser('username', $starting_offset, $limit);

Changing the behavior of the HTTP Client

If for whatever reason you would like to change the behavior of the HTTP client when making the web service request, you can do so by creating your own instance of the Zend_Http_Client object (see Zend_Http). This is useful for instance when it is desirable to set the timeout for the connection to something other then default as shown:

  1. $client = new Zend_Http_Client();
  2. $client->setConfig(array('timeout' => 5));
  3.  
  4. $ss = new Zend_Service_SlideShare('APIKEY',
  5.                                   'SHAREDSECRET',
  6.                                   'USERNAME',
  7.                                   'PASSWORD');
  8. $ss->setHttpClient($client);
  9. $ss_user = $ss->getSlideShowsByUser('username', $starting_offset, $limit);

Copyright

© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts