imgur

package module
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: BSD-3-Clause Imports: 11 Imported by: 1

README ¶

Golang Imgur API

Repo Size Go

🗃 Install

go get -d github.com/MedzikUser/go-imgur

🗒 Docs

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type AccessTokenResponse ¶ added in v0.2.0

type AccessTokenResponse struct {
	// Access Token
	AccessToken string `json:"access_token"`
	// Token Expires Time
	Expires uint `json:"expires_in"`
	// Tonen Type "bearer"
	TokenType string `json:"token_type"`
	// Refresh Token
	RefreshToken string `json:"refresh_token"`
	// Imgur Account ID
	AccountID uint `json:"account_id"`
	// Account Username
	Username string `json:"account_username"`
}

type Client ¶

type Client struct {
	HTTPClient *http.Client
	Imgur      Imgur
}

Imgur API Client

func (*Client) DeleteImageAuthed ¶

func (client *Client) DeleteImageAuthed(id string) (*ImageInfoWithoutData, int, error)

Delete Image from Ingur using Bearer

info, status, err := DeleteImageAuthed("abc")

func (*Client) DeleteImageUnAuthed ¶

func (client *Client) DeleteImageUnAuthed(hash string) (*ImageInfoWithoutData, int, error)

Delete Image from Ingur using Client-ID

info, status, err := DeleteImageUnAuthed("deleteHash")

func (*Client) GenerateAccessToken ¶ added in v0.2.0

func (client *Client) GenerateAccessToken(refreshToken string) (*AccessTokenResponse, error)

Generate Access Token (Bearer)

res, err := client.GenerateAccessToken("abc")

func (*Client) GetImageInfo ¶ added in v0.3.0

func (client *Client) GetImageInfo(imageID string) (*ImageInfoData, int, error)

Get Image Info from Imgur

info, status, err := client.GetImageInfo("abc")

func (*Client) RateLimits ¶ added in v0.8.0

func (client *Client) RateLimits() (*RateLimitsStruct, int, error)

Get Image Info from Imgur

info, status, err := client.RateLimits()

func (*Client) UploadImage ¶

func (client *Client) UploadImage(img string, dtype string, album string) (*ImageInfoData, int, error)

Upload Image to Imgur

info, status, err := client.UploadImage("https://example.com/example.png", "url", "abc")

func (*Client) UploadImageFromFile ¶

func (client *Client) UploadImageFromFile(path string, album string) (*ImageInfoData, int, error)

Upload Image to Imgur by File

info, status, err := client.UploadImageFromURL("path/to/img", "")

func (*Client) UploadImageFromURL ¶

func (client *Client) UploadImageFromURL(imgUrl string, album string) (*ImageInfoData, int, error)

Upload Image to Imgur by URL

info, status, err := client.UploadImageFromURL("https://abc/img", "")

type ImageInfo ¶

type ImageInfo struct {
	// Imgur img ID e.g. abcde123098
	ID string `json:"id"`
	// ID with extention e.g. abcde123098.png
	IDExt string
	// Image Title
	Title string `json:"title"`
	// Image Description
	Description string `json:"description"`
	// Image Upload Datetime
	Datetime int `json:"datetime"`
	// Type Format
	MimeType string `json:"type"`
	// Image is animated?
	Animated bool `json:"animated"`
	// Image width
	Width int `json:"width"`
	// Image height
	Height int `json:"height"`
	// Image File Size
	Size int `json:"size"`
	// Image Views
	Views int `json:"views"`
	// Imgur Bandwidth
	Bandwidth int `json:"bandwidth"`
	// Imgur Delete Hash
	Deletehash string `json:"deletehash,omitempty"`
	// The name of the file
	Name    string `json:"name,omitempty"`
	Section string `json:"section"`
	// Image URL e.g. https://i.imgur.com/abcde123098.png
	Link     string `json:"link"`
	Gifv     string `json:"gifv,omitempty"`
	Mp4      string `json:"mp4,omitempty"`
	Mp4Size  int    `json:"mp4_size,omitempty"`
	Looping  bool   `json:"looping,omitempty"`
	Favorite bool   `json:"favorite"`
	// Image is Nsfw?
	Nsfw      bool   `json:"nsfw"`
	Vote      string `json:"vote"`
	InGallery bool   `json:"in_gallery"`
}

type ImageInfoData ¶

type ImageInfoData struct {
	// Image Info
	Data *ImageInfo `json:"data"`
	// Action successfully performed?
	Success bool `json:"success"`
	// Imgur HTTP Code
	Status int `json:"status"`
}

type ImageInfoWithoutData ¶

type ImageInfoWithoutData struct {
	// Action successfully performed?
	Success bool `json:"success"`
	// Imgur HTTP Code
	Status int `json:"status"`
}

type Imgur ¶

type Imgur struct {
	// Imgur Client-ID
	ClientID string
	// Imgur Client Secret
	ClientSecret string

	// Imgur Access Token
	//	client.GenerateAccessToken()
	AccessToken string
}

type RateLimitsData ¶ added in v0.8.0

type RateLimitsData struct {
	UserLimit       int `json:"UserLimit"`
	UserRemaining   int `json:"UserRemaining"`
	UserReset       int `json:"UserReset"`
	ClientLimit     int `json:"ClientLimit"`
	ClientRemaining int `json:"ClientRemaining"`
}

type RateLimitsStruct ¶ added in v0.8.0

type RateLimitsStruct struct {
	Data    RateLimitsData `json:"data"`
	Success bool           `json:"success"`
	Status  int            `json:"status"`
}

Directories ¶

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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