Sina Weibo SDK for Go language, supporting all Weibo API features
go get -u github.com/yafengio/weibogo
Fetch the latest 10 posts from @People's Daily:
package main
import (
"flag""fmt""github.com/yafengio/weibogo"
)
var (
weibo= weibogo.Weibo{}
access_token=flag.String("access_token", "", "User's access token")
)
funcmain() {
// Parse command line argumentsflag.Parse()
// Call APIvarstatuses weibogo.Statusesparams:= weibogo.Params{"screen_name": "人民日报", "count": 10}
err:=weibo.Call("statuses/user_timeline", "get", *access_token, params, &statuses)
// Process resultsiferr!=nil {
fmt.Println(err)
return
}
for_, status:=rangestatuses.Statuses {
fmt.Println(status.Text)
}
}Pass the access token via the command line parameter -access_token. The token can be obtained through the API Testing Tool or weibogo.Authenticator.
For more API call examples, see examples/weibo.go.