slideshare

package module
v0.0.0-...-20589f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2014 License: MIT Imports: 9 Imported by: 0

README

slideshare

API wrapper for SlideShare written in Go. Everything is in a very initial stage...preparation, arrangement and stuff.

Installation

When everything is ready, package installation should be done via command bellow:

go get github.com/dmtar/slideshare

Methods

Tested:

  • add_favorite
  • check_favorite
  • delete_slideshow
  • edit_slideshow
  • get_slideshow
  • get_slideshows_by_tag
  • get_slideshows_by_user
  • get_user_contacts
  • get_user_favorites
  • search_slideshows
  • upload_slideshow

Not working for some reasons:

  • get_slideshow_by_group (500 Internal Server Error)
  • get_user_groups (after redirecting returns "This is probably a temporary error, please check back in 5-10 minutes.")

Methods below require a PRO account to be used and tested, they are not implemented. There is no info about the XML structure on the slideshare website.

  • get_user_campaign_leads
  • get_user_campaigns
  • get_user_leads

Examples

package main

import (
    "fmt"
    "github.com/dishev/slideshare"
)

func main() {
    service := slideshare.Service{"API_KEY", "SHARED_SECRET"}
    slideshow, err := service.GetSlideshow(30975136)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println("ID: ", slideshow.ID)
    fmt.Println("Title: ", slideshow.Title)
    fmt.Println("Username: ", slideshow.Username)
}

Documentation

Overview

Package slideshare provides API wrapper for SlideShare.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Btoa

func Btoa(input bool) string

Cast bool to string

Types

type DeletedSlideshow

type DeletedSlideshow struct {
	DeletedID int `xml:"SlideshowID"`
}

type EditedSlideshow

type EditedSlideshow struct {
	EditedID int `xml:"SlideShowID"`
}

type Favorite

type Favorite struct {
	SlideshowID int    `xml:"SlideshowID"`
	UserID      uint64 `xml:"User"`
	Favorited   bool   `xml:"Favorited"`
}

Favorite type keeps the information about favorited slideshow by the user

type Group

type Group struct {
	Name          string `xml:"name"`
	NumPosts      uint32 `xml:"numposts"`
	NumSlideshows uint32 `xml:"numslideshows"`
	NumMembers    uint32 `xml:"nummembers"`
	Created       string `xml:"created"`
	QueryName     string `xml:"queryname"`
	Url           string `xml:"url"`
}

type Groups

type Groups struct {
	Values []Group `xml:"group"`
}

type Service

type Service struct {
	ApiKey       string
	SharedSecret string
}

Type Service defines the service, it needs Api key and Shared Secret you can obtain them from slideshare website.

func (*Service) AddFavorite

func (s *Service) AddFavorite(username string, password string, slideshow_id int) bool

Add favorite favorites a slideshow. Needs username and password of the requesting user and id of the slideshow to be favorited.

func (*Service) CheckFavorite

func (s *Service) CheckFavorite(username string, password string, slideshow_id int) (Favorite, error)

Check user favorite needs username and password of the requesting user and id of the slideshow which is being checked, whether is favorited by the user.

func (*Service) DeleteSlideshow

func (s *Service) DeleteSlideshow(username string, password string, slideshowID int) bool

Delete a slideshow needs username and password of the requesting user and slideshow ID.

func (*Service) EditSlideshow

func (s *Service) EditSlideshow(username string, password string, slideshowID int, additionalParams ...string) bool

Edit a Slideshow needs username and password of the owner of the requesting user and slideshow id other parameters are new title, new tags and make the slideshow private, generate secret url, allow embeds and share with contacts are optinal.You have to pass their values like strigs.

func (*Service) GetSlideshow

func (s *Service) GetSlideshow(id int, detailed bool) (Slideshow, error)

GetSlideshow returns information about a slideshow needs id of the slideshow to be fetched, and detailed flag.

Example

You have to get API_KEY & SHARED_SECRET from Slideshare Here we are creating our service by providing the API_KEY & SHARED_SECRET After we call the method GetSlideshow with the Slideshow ID and without detailed information if you want detailed information for the slideshow, second argument has to be true, if everything is ok we have slideshow object with all the properties.

service := slideshare.Service{"5Pl6RFlI", "X1lMfjPo"}
slideshow, err := service.GetSlideshow(30975136, false)
if err != nil {
	fmt.Println("Error:")
	fmt.Println(err)
}
fmt.Println("ID:", slideshow.ID)
fmt.Println("Title:", slideshow.Title)
fmt.Println("Username:", slideshow.Username)
Output:

ID: 30975136
Title: Do not delete!
Username: ddishev

func (*Service) GetSlideshowsByTag

func (s *Service) GetSlideshowsByTag(tag string, detailed bool, limitOffset ...int) (SlideshowsByTag, error)

GetSlideshowByTag need tag name and detailed flag limit and offset are optional if they are used, should be passed in that way limit first then offset.

Example

Getting slideshows which have "sql" tag.

service := slideshare.Service{"5Pl6RFlI", "X1lMfjPo"}
slideshows, err := service.GetSlideshowsByTag("dishev", false)
if err != nil {
	fmt.Println("Error:")
	fmt.Println(err)
}
fmt.Println("ID:", slideshows.Slideshows[0].ID)
fmt.Println("Title:", slideshows.Slideshows[0].Title)
fmt.Println("Username:", slideshows.Slideshows[0].Username)
Output:

ID: 30975136
Title: Do not delete!
Username: ddishev

func (*Service) GetSlideshowsByUser

func (s *Service) GetSlideshowsByUser(username string, detailed bool, limitOffset ...int) (SlideshowsByUser, error)

GetSlideshowByUser needs username and detailed flag arguments, others like limit and offset are optional.Should be passed in that way limit first then offset.

Example
service := slideshare.Service{"5Pl6RFlI", "X1lMfjPo"}
slideshows, err := service.GetSlideshowsByUser("ddishev", false)
lastSlideshowIndex := slideshows.Count - 1
if err != nil {
	fmt.Println("Error:")
	fmt.Println(err)
}
fmt.Println("ID:", slideshows.Slideshows[lastSlideshowIndex].ID)
fmt.Println("Title:", slideshows.Slideshows[lastSlideshowIndex].Title)
fmt.Println("Username:", slideshows.Slideshows[lastSlideshowIndex].Username)
Output:

ID: 30975136
Title: Do not delete!
Username: ddishev

func (*Service) GetUserContacts

func (s *Service) GetUserContacts(username_for string, limitOffset ...int) (UserContacts, error)

GetUserContacts needs username of user whose Contacts are being requested. You can 1 additional parameter int to specify number of items to return.

func (*Service) GetUserFavorites

func (s *Service) GetUserFavorites(username_for string) (UserFavorites, error)

GetUserFavorites needs username of user whose Favorites are being requested.

func (*Service) GetUserTags

func (s *Service) GetUserTags(username string, password string) (Tags, error)

GetUserTags needs username and password of the requesting user.

func (*Service) SearchSlideshows

func (s *Service) SearchSlideshows(queryString string, detailed bool, additionalParams ...string) (SlideshowsSearch, error)

Search for a slideshow needs query string and detailed flag arguments Optional are page default is 1, items per page default is 12, sort type default is relevance, and upload date default is any If you want to change the default values of additional parameters, you should pass them like that: page,items_per_page,sort,upload_date and values casted to string.

func (*Service) UploadSlideshow

func (s *Service) UploadSlideshow(username string, password string, uploadURL string, slideshowTitle string, additionalParams ...string) (int, bool)

This method requires extra permissions. If you want to upload a file using SlideShare API, please send an email to api@slideshare.com with your developer account username describing the use case. The method requires username and password of the requesting user, title and upload url string containing an url pointing to the power point file: ex: http://domain.tld/directory/my_power_point.ppt The following urls are also acceptable http://www.domain.tld/directory/file.ppt http://www.domain.tld/directory/file.cgi?filename=file.ppt Optinal parameters are description of the slideshow and slideshow tags.

type Slideshow

type Slideshow struct {
	ID                uint64   `xml:"ID"`
	Title             string   `xml:"Title"`
	Description       string   `xml:"Description"`
	Username          string   `xml:"Username"`
	Status            uint8    `xml:"Status"`
	Url               string   `xml:"URL"`
	ThumbnailUrl      string   `xml:"ThumbnailURL"`
	ThumbnailSize     string   `xml:"ThumbnailSize"`
	ThumbnailSmallUrl string   `xml:"ThumbnailSmallURL"`
	Embed             string   `xml:"Embed"`
	Created           string   `xml:"Created"`
	Updated           string   `xml:"Updated"`
	Language          string   `xml:"Language"`
	Format            string   `xml:"Format"`
	Download          bool     `xml:"Download"`
	DownloadUrl       string   `xml:"DownloadUrl"`
	SlideshowType     uint8    `xml:"SlideshowType"`
	InContest         bool     `xml:"InContest"`
	UserID            uint64   `xml:"UserID"`
	PPTLocation       string   `xml:"PPTLocation"`
	StrippedTitle     string   `xml:"StrippedTitle"`
	Tags              []string `xml:"Tags>Tag"`
	Audio             bool     `xml:"Audio"`
	NumDownloads      uint32   `xml:"NumDownloads"`
	NumViews          uint32   `xml:"NumViews"`
	NumComments       uint32   `xml:"NumComments"`
	NumFavorites      uint32   `xml:"NumFavorites"`
	NumSlides         uint16   `xml:"NumSlides"`
	RelatedSlideshows []uint64 `xml:"RelatedSlideshows>RelatedSlideshowID"`
	PrivacyLevel      bool     `xml:"PrivacyLevel"`
	FlagVisible       bool     `xml:"FlagVisible"`
	ShowOnSS          bool     `xml:"ShowOnSS"`
	SecretURL         bool     `xml:"SecretUrl"`
	AllowEmbed        bool     `xml:"AllowEmbed"`
	ShareWithContacs  bool     `xml:"ShareWithContacs"`
}

Slideshow type, which holds all the information about a slideshow properties bellow InContest are detailed, they will have reliabe information if detailed flag is set to true.

type SlideshowsByTag

type SlideshowsByTag struct {
	TagName    string      `xml:"Name"`
	Count      uint32      `xml:"Count"`
	Slideshows []Slideshow `xml:"Slideshow"`
}

SlideshowsByTag struct keeps the Tag we are looking for Count of all found slideshow and array with them.

type SlideshowsByUser

type SlideshowsByUser struct {
	UserName   string      `xml:"Name"`
	Count      uint32      `xml:"Count"`
	Slideshows []Slideshow `xml:"Slideshow"`
}

SlideshowsByUser struct keeps the username we are looking for Count of all found slideshow and array with them.

type SlideshowsSearch

type SlideshowsSearch struct {
	QueryString  string      `xml:"Meta>Query"`
	NumResults   uint32      `xml:"Meta>NumResults"`
	TotalResults uint64      `xml:"Meta>TotalResults"`
	Slideshows   []Slideshow `xml:"Slideshow"`
}

SlideshowsByUser struct keeps the query string. offset of the result,results per page and total results and array with slideshows.

type Tags

type Tags struct {
	Names []string `xml:"Tag"`
}

type UploadedSlideshow

type UploadedSlideshow struct {
	UploadedID int `xml:"SlideShowID"`
}

type UserContact

type UserContact struct {
	Username      string `xml:"Username"`
	NumSlideshows uint32 `xml:"NumSlideshows"`
	NumComments   uint32 `xml:"NumComments"`
}

type UserContacts

type UserContacts struct {
	Values []UserContact `xml:"Contact"`
}

type UserFavorite

type UserFavorite struct {
	SlideshowID uint64 `xml:"slideshow_id"`
	TagText     string `xml:"tag_text"`
}

type UserFavorites

type UserFavorites struct {
	Values []UserFavorite `xml:"favorite"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL