Skip to content

zhangxinngang/gobo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages