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")
)
func main() {
// Parse command line arguments
flag.Parse()
// Call API
var statuses weibogo.Statuses
params := weibogo.Params{"screen_name": "人民日报", "count": 10}
err := weibo.Call("statuses/user_timeline", "get", *access_token, params, &statuses)
// Process results
if err != nil {
fmt.Println(err)
return
}
for _, status := range statuses.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.