Giter Club home page Giter Club logo

go-tenor's Introduction

go-tenor

A tenor.com API wrapper for the Go programming language.

Installation

Configure $GOPATH correctly then

go get github.com/jkershaw2000/go-tenor

Usage

Search for a GIF

Allow the user to search for a gif hosted on tenor. GetSearch takes 4 parameters

query (string) - the search term

filter ("off", "low", "medium", "high) - content filtering

locale (2 letter ISO country code) - what langauge the search is in

limit (int, -1 for no limit ) - max number of search results

package main

import (
	"fmt"
	"github.com/jkershaw2000/go-tenor"
)
const (
    APIKey = "YOUR_API_KEY"
)

func main() {
	t := gotenor.NewTenor(APIKey)

	data, err := t.GetSearch("Query", "", "", -1)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(data)
}

Get single ID

Returns all data about a GIF. GetByID takes a single parameter

id (string) - gif id

package main

import (
    "fmt"
    "github.com/jkershaw2000/go-tenor"
)
const (
    APIKey = "YOUR_API_KEY"
)

func main() {
    tenor := gotenor.NewTenor(APIKey)

    gifID := "8776030"
    data, err := tenor.GetByID(gifID)
    if err != nil {
        fmt.Println("Error: ", err)
    }
    fmt.Println(data)
}

Get gif URL from tenorData structure

There are two helper methods to get just the URLs for gifs to share.

GetGifURL(data tenorData) - returns the first 'gif' url

GetAllGifURLS(data tenorData) - returns all 'gif' urls found

package main

import (
    "fmt"
    "github.com/jkershaw2000/go-tenor"
)
const (
    APIKey = "YOUR_API_KEY"
)

func main() {
    tenor := gotenor.NewTenor(APIKey)
    gifID := "8776030,17437428"
    data, err := tenor.GetByID(gifID)
    if err != nil {
        fmt.Println("Error: ", err)
    }
    fmt.Println(libtenor.GetGifURL(*data)) // single URL
    fmt.Println(libtenor.GetAllGifURLS(*data)) // All urls
}

Credits

A lot of the code was adapted from sanzaru's go-giphy which can be found here.

go-tenor's People

Contributors

jkershaw2000 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

natsuokawai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.