gotenor

package module
v0.0.0-...-5da7318 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 7 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllGifURLS

func GetAllGifURLS(data tenorData) []string

GetAllGifURLS retuns all the 'gif URLs found in a tenorData struct.

func GetGifURL

func GetGifURL(data tenorData) string

GetGifURLS returns the URl of the 'gif' media type from a given tenorData struct. Always returns the URl of first gif in the data structure.

Types

type Tenor

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

Tenor is the gerneal Tenor class

func NewTenor

func NewTenor(apiKey string) *Tenor

NewTenor is a constructor to create a Tenor struct.

func (*Tenor) GetById

func (t *Tenor) GetById(id string) (*tenorData, error)

GetById fetches GIF information based on the given ID More inforation: https://tenor.com/gifapi/documentation#endpoints-gifs

func (*Tenor) GetSearch

func (t *Tenor) GetSearch(query, filter, locale string, limit int) (*tenorData, error)

GetSearch provides an implementation of the tenor search endpoint. It requires a query, filter(off, low, medium, high), locale(2 letter ISO country codes) and limit(-1 for unlimited) Returns tenorData struct.

Jump to

Keyboard shortcuts

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