flickgo

package module
v0.0.0-...-227fc62 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2014 License: Apache-2.0 Imports: 16 Imported by: 1

README

Flickgo

This is a fork of the code.google.com hosted library (https://code.google.com/p/flickgo/) written originally by https://github.com/manki

This is a client library written in Google's Go language for interacting with Flickr's REST API. Primary development focus is to be compatible with Google App Engine's server environment.

Library has support for only a few API calls. If you need to use a call that's not yet implemented, adding it is trivial. Email me for support; or maybe I can even add it for you.

Documentation

Overview

Flickr library for Go. Created to be used primarily in Google App Engine.

Index

Constants

View Source
const (
	ReadPerm   = "read"
	WritePerm  = "write"
	DeletePerm = "delete"
)

Flickr API permission levels. See http://www.flickr.com/services/api/auth.spec.html.

View Source
const (
	SizeSmallSquare = "s"
	SizeThumbnail   = "t"
	SizeSmall       = "m"
	SizeMedium500   = "-"
	SizeMedium640   = "z"
	SizeLarge       = "b"
	SizeOriginal    = "o"
)

Image sizes supported by Flickr. See http://www.flickr.com/services/api/misc.urls.html for more information.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Auth token for acting on behalf of a user.
	AuthToken string

	// Logger to use.
	// Hint: App engine's Context implements this interface.
	Logger Debugfer
	// contains filtered or unexported fields
}

Flickr client.

func New

func New(apiKey string, secret string, httpClient *http.Client) *Client

Creates a new Client object. See http://www.flickr.com/services/api/misc.api_keys.html for learning about API key and secret. For App Engine apps, you can create httpClient by calling urlfetch.Client function; other apps can pass http.DefaultClient.

func (*Client) AddPhotoToSet

func (c *Client) AddPhotoToSet(photoID, setID string) error

Adds a photo to a photoset.

func (*Client) AuthURL

func (c *Client) AuthURL(perms string) string

Returns the URL for requesting authorisation to access the user's Flickr account. List of possible permissions are defined at http://www.flickr.com/services/api/auth.spec.html. You can also use one of the following constants:

ReadPerm
WritePerm
DeletePerm

func (*Client) CheckTickets

func (c *Client) CheckTickets(tickets []string) (statuses []TicketStatus, err error)

Checks the status of async upload tickets (returned by Upload method, for example). Interface for http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html API method.

func (*Client) GetInfo

func (c *Client) GetInfo(photoId string) (*InfoResponse, error)

func (*Client) GetSets

func (c *Client) GetSets(userID string) ([]PhotoSet, error)

Returns the list of photo sets of the specified user.

func (*Client) GetSizes

func (c *Client) GetSizes(photoId string) (*SizesResponse, error)

func (*Client) GetToken

func (c *Client) GetToken(frob string) (string, *User, error)

Exchanges a temporary frob for a token that's valid forever. See http://www.flickr.com/services/api/auth.howto.web.html.

func (*Client) Search

func (c *Client) Search(args map[string]string) (*SearchResponse, error)

Searches for photos. args contains search parameters as described in http://www.flickr.com/services/api/flickr.photos.search.html.

func (*Client) Upload

func (c *Client) Upload(name string, photo []byte,
	args map[string]string) (ticketID string, err error)

Initiates an asynchronous photo upload and returns the ticket ID. See http://www.flickr.com/services/api/upload.async.html for details.

type Dates

type Dates struct {
	Posted           string `xml:"posted,attr"` // Unix timestamp
	Taken            string `xml:"taken,attr"`
	Takengranularity int    `xml:"takengranularity,attr"`
	Lastupdate       string `xml:"lastupdate,attr"`
}

func (*Dates) LastupdateTime

func (d *Dates) LastupdateTime() time.Time

func (*Dates) PostedTime

func (d *Dates) PostedTime() time.Time

func (*Dates) TakenTime

func (d *Dates) TakenTime() time.Time

type Debugfer

type Debugfer interface {
	// Debugf formats its arguments according to the format, analogous to fmt.Printf,
	// and records the text as a log message at Debug level.
	Debug(format string, args ...interface{})
}

Debug logger.

type InfoResponse

type InfoResponse struct {
	Photo

	Rotation    string     `xml:"rotation,attr"`
	License     string     `xml:"license,attr"`
	Description string     `xml:"description"`
	Visibility  Visibility `xml:"visibility"`
	Dates       Dates      `xml:"dates"`
	Tags        []Tag      `xml:"tags>tag"`
	Urls        []Url      `xml:"urls>url"`
	Title       string     `xml:"title"`
}

type Photo

type Photo struct {
	ID     string `xml:"id,attr"`
	Secret string `xml:"secret,attr"`
	Server string `xml:"server,attr"`
	Farm   string `xml:"farm,attr"`
}

func (*Photo) URL

func (p *Photo) URL(size string) string

Returns the URL to this photo in the specified size.

type PhotoSet

type PhotoSet struct {
	ID          string `xml:"id,attr"`
	Title       string `xml:"title"`
	Description string `xml:"description"`
}

type SearchPhoto

type SearchPhoto struct {
	Photo

	Owner    string `xml:"owner,attr"`
	IsPublic string `xml:"ispublic,attr"`
	Width_T  string `xml:"width_t,attr"`
	Height_T string `xml:"height_t,attr"`
	Title    string `xml:"title,attr"`

	Width  int `xml:"o_width,attr"`
	Height int `xml:"o_height,attr"`

	// Photo's aspect ratio: width divided by height.
	Ratio float64
}

Represents a Flickr photo.

type SearchResponse

type SearchResponse struct {
	Page    string        `xml:"page,attr"`
	Pages   string        `xml:"pages,attr"`
	PerPage string        `xml:"perpage,attr"`
	Total   string        `xml:"total,attr"`
	Photos  []SearchPhoto `xml:"photo"`
}

Response for photo search requests.

type Size

type Size struct {
	Label  string `xml:"label,attr"`
	Width  int    `xml:"width,attr"`
	Height int    `xml:"height,attr"`
	Source string `xml:"source,attr"`
	Url    string `xml:"url,attr"`
}

type SizesResponse

type SizesResponse struct {
	Canblog     bool   `xml:"canblog,attr"`
	Canprint    bool   `xml:"canprint,attr"`
	Candownload bool   `xml:"candownload,attr"`
	Sizes       []Size `xml:"size"`
}

type Tag

type Tag struct {
	ID   string `xml:"id,attr"`
	Text string `xml:",chardata"`
}

type TicketStatus

type TicketStatus struct {
	ID       string `xml:"id,attr"`
	Complete string `xml:"complete,attr"`
	Invalid  string `xml:"invalid,attr"`
	PhotoID  string `xml:"photoid,attr"`
}

Asynchronous photo upload status response.

type Url

type Url struct {
	Type string `xml:"type,attr"`
	Href string `xml:",chardata"`
}

type User

type User struct {
	UserName string `xml:"username,attr"`
	NSID     string `xml:"nsid,attr"`
}

A Flickr user.

type Visibility

type Visibility struct {
	IsPublic bool `xml:"ispublic,attr"`
	IsFriend bool `xml:"isfriend,attr"`
	IsFamily bool `xml:"isfamily,attr"`
}

Jump to

Keyboard shortcuts

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