gobo

by huichen

huichen / gobo

新浪微博Go语言SDK

127 Stars 38 Forks Last release: Not found Other 44 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

gobo

新浪微博Go语言SDK,支持所有微博API功能

安装/更新

go get -u github.com/huichen/gobo

使用

抓取@人民日报的最近10条微博:

package main

import ( "flag" "fmt" "github.com/huichen/gobo" )

var ( weibo = gobo.Weibo{} access_token = flag.String("access_token", "", "用户的访问令牌") )

func main() { // 解析命令行参数 flag.Parse()

// 调用API
var statuses gobo.Statuses
params := gobo.Params{"screen_name": "人民日报", "count": 10}
err := weibo.Call("statuses/user_timeline", "get", *access_token, params, &statuses)

// 处理返回结果
if err != nil {
    fmt.Println(err)
    return
}
for _, status := range statuses.Statuses {
    fmt.Println(status.Text)
}

}

用命令行参数-access_token传入访问令牌,令牌可以通过API测试工具或者gobo.Authenticator得到。

更多API调用的例子见 examples/weibo.go

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.