Skip to content

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

Notifications You must be signed in to change notification settings

maratrixx/weibogo

Repository files navigation

weibogo

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

安装/更新

go get -u github.com/maratrixx/weibogo

使用

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

package main

import (
	"flag"
	"fmt"
	"github.com/maratrixx/weibogo"
)

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

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

	// 调用API
	var statuses weibogo.Statuses
	params := weibogo.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测试工具或者weibogo.Authenticator得到。

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages