Fanfou SDK for Golang
- Simple API and Error wrapping
- Supports OAuth and XAuth
- Use secure HTTPS protocol
$ go get -u github.com/haozibi/fanfou-sdk-golang
Use Environment FANFOU_SDK_DEBUG
to enable debug mode:
$ FANFOU_SDK_DEBUG=true go run examples/status/main.go
$ go run example/oauth/main.go\
-consumerKey <consumerKey>\
-consumerSecret <consumerSecret>
$ go run example/oauth_oob/main.go\
-consumerKey <consumerKey>\
-consumerSecret <consumerSecret>
$ go run examples/status/main.go \
-consumerKey <consumerKey>\
-consumerSecret <consumerSecret>\
-password <password>\
-username <username>\
-status "在这里,无人知晓你是谁"
$ go run examples/status/main.go \
-consumerKey <consumerKey>\
-consumerSecret <consumerSecret>\
-password <password>\
-username <username>\
-status "在这里,无人知晓你是谁"\
-picture https://i.loli.net/2019/12/12/gYRoF4exsyNCc5J.jpg
$ go run examples/status/main.go \
-consumerKey <consumerKey>\
-consumerSecret <consumerSecret>\
-password <password>\
-username <username>
More Example Example
- All Error Wrap By "github.com/pkg/errors"
- API Response Error use
ErrorResponse
struct
import pkgErr "github.com/pkg/errors"
func TestError(t *testing.T) {
var f fanfou.Fanfou
_, err := f.AccountService.VerifyCredentials(context.Background())
if err != nil {
err = pkgErr.Cause(err)
var e *utils.ErrorResponse
if errors.As(err, &e) {
fmt.Println(e.GetStatusCode())
fmt.Println(e.GetErrorMsg())
fmt.Println(e.GetRequest())
} else {
fmt.Println(e)
}
}
}
- Do not support callback
- Only API v1
MIT