vimeo

package module
v0.0.0-...-bc71108 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2016 License: MIT Imports: 1 Imported by: 0

README

gimeo

This is a Go library to consume the Vimeo API. More information on the API can be found on the official page.

Installation

All you need to do is run:

go get https://github.com/julianedialkova/gimeo.git

Then you can enjoy the library!

Using the library

First steps

In order to make requests to the API you must first run the following function:

var client = Vimeo("clientID", "clientSecret", "accessToken")

You should provide your client ID and secret. They can be found on your app page under the Authentication tab. You can create an app here.

You can also provide an access token, but it is optional. It is required in order to make requests. Below you can find information how to generate one.

Generate an access token

There are two ways to make requests to the Vimeo API - through authenticated and unauthenticated tokens. First you should have called the Vimeo function to generate a client.

  1. Unauthenticated token

This is a token without a user. All you can see using this token is public data. If you want to generate one, just use:

client.GenerateUnauthAccessToken([]string{"create"})

Where scopes look like this: []string{"public"}.

As an argument you should pass the scopes you want to access. Description of the scopes can be found on the official page.

  1. Authenticated token

This token uses the user. It interacts on behalf of the authenticated user. In order to generate one, you should:

GenerateAuthAccessToken is the first step of the redirect process is to send the user's client (browser) to vimeo.com. This is generally accomplished by providing the authorize url as a link on a webpage.

```
client.GenerateАuthAccessToken("redirectURI", scopes, "state")
```
Where scopes look like this: `[]string{"public"}`.
Name Description
redirectURI This must be required, and must match your app callback URL
state A unique value which the client will return alongside access tokens

If the user accepts your app, they are redirected to your redirect_uri along with two parameters.

Name Description
code A string token you must exchange for your access token
state The state you provided earlier. You must validate that this matches your original state. If the state does not match, you should not attempt to exchange the authorization code.

When the user returns to your site, you must exchange the code for your access token. Make an HTTP POST request to https://api.vimeo.com/oauth/access_token with your authorization header, and the following parameters.

```
client.GetToken("code", "redirectURI")
```
Make a request

When you have all ready making a request is really simple:

params := &Parameters{
	"per_page": 10,
 }

 client.GetMyAlbums(params)
Upload a video

You may also upload a video.

  1. Upload a video
params := &Parameters{
   	"type": "streaming",
   }
client.Upload("/path/to/video.mp4")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthEndpoints

type AuthEndpoints struct {
	// contains filtered or unexported fields
}

AuthEndpoints are the main authorization endpoints

Default ones will be:

// authorization : '/oauth/authorize', // accessToken : '/oauth/access_token', // clientCredentials : '/oauth/authorize/client'

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the type of object that identifies the user.

func Vimeo

func Vimeo(clientID, clientSecret, accessToken string) *Client

Vimeo - used to interact with the Vimeo API

func (*Client) GenerateAuthAccessToken

func (c *Client) GenerateAuthAccessToken(code, redirectURI, state string) string

GenerateAuthAccessToken generates an access token it order to make authorized requests The function takes code and a redirect_uri and returns an access_token.

func (*Client) GenerateUnauthAccessToken

func (c *Client) GenerateUnauthAccessToken(scopes []string)

GenerateUnauthAccessToken generates an access token it order to make authorized requests The function takes code and a redirect_uri and returns an access_token.

func (*Client) Request

func (c *Client) Request(options []byte) (response []byte, err error)

Request performs an api call. There are two ways for that:

  1. Provide only URL If an URL is provided, then the default settings will be set. => GET https://api.vimeo.com/{url provided}
  1. Options If there is a options map provided, then those elements will be added to the request query. The only required one is options["path"].Options can include hostname, port, query (applied to the URL if the method is GET and in the request body if POST), headers, path (can also include a querystring) and method.

The function will return the response body and error.

func (*Client) UploadVideo

func (c *Client) UploadVideo(path, videoURI string)

UploadVideo is used in order to upload a video to Vimeo

type Request

type Request struct {
	Path string `json:"path"`

	Method  string `json:"method"`
	Query   map[string]string
	Headers map[string]string
	// contains filtered or unexported fields
}

Request shows the structure of a request Default ones will be: protocol : 'https:', hostname : 'api.vimeo.com', port : 443, method : 'GET', query : {},

headers : {
	Accept: "application/vnd.vimeo.*+json;version=3.2",
	'User-Agent': 'Vimeo.js/1.1.4'

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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