go-xREL-API

module
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 License: GPL-3.0

README

xREL API Package

GoDoc

A golang package to authorize with and access the complete xrel.to API.

Import this way:

import github.com/hashworks/go-xREL-API/xrel

All methods may return a types.Error struct, which implements the normal error type. Additional to the Error() function this struct contains the variables Type and Code. Errors with type api are xREL.to errors, for all other types and error codes see the xrel/types/errors.go file.

To use this in your code try to cast it:

err := xrel.SomeMethod()
if eErr, ok := err.(*types.Error); ok {
	// Is of type types.Error, you can use the variables
} else {
	// Is normal error
}

If you use the OAuth authentication make sure to save the Config variable somewhere and set it again on your next run. Here is an example how to use the OAuth2 authentication:

xrel.ConfigureOAuth2("OAUTH2_CLIENT_KEY", "OAUTH2_CLIENT_SECRET", "", []string{"viewnfo", "addproof"})

fmt.Println("(1) Go to: " + xrel.GetOAuth2AuthURL(""))
fmt.Println("(2) Grant access, you should get back a verification code.")
fmt.Print("(3) Enter that verification code here: ")
verificationCode := ""
fmt.Scanln(&verificationCode)

err := xrel.PerformOAuth2UserAuthentication(verificationCode)
ok(err)

Directories

Path Synopsis
Package xrel contains functions to authorize with and access the complete xREL.to API.
Package xrel contains functions to authorize with and access the complete xREL.to API.
types
Package types contains structs and constants for the xREL package, reflecting the xREL API JSON returns.
Package types contains structs and constants for the xREL package, reflecting the xREL API JSON returns.

Jump to

Keyboard shortcuts

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