Documentation ¶
Index ¶
- Constants
- type AccessToken
- type AccessTokenInfo
- type Authenticator
- func (auth *Authenticator) AccessToken(code string) (AccessToken, error)
- func (auth *Authenticator) Authorize() (string, error)
- func (auth *Authenticator) GetTokenInfo(token string) (AccessTokenInfo, error)
- func (auth *Authenticator) Init(redirectUri string, clientId string, clientSecret string) error
- func (auth *Authenticator) Revokeoauth2(token string) error
- type Comment
- type ErrorString
- type Geo
- type Params
- type Pic_Url
- type Privacy
- type Remind
- type Status
- type Statuses
- type Url_Short
- type User
- type Visible
- type Weibo
- type WeiboError
Constants ¶
View Source
const ( ApiDomain string = "https://api.weibo.com" ApiVersion string = "2" UploadAPIName string = "statuses/upload" ApiNamePostfix string = ".json" )
微博API相关的常数
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessTokenInfo ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator结构体实现了微博应用授权功能
func (*Authenticator) AccessToken ¶
func (auth *Authenticator) AccessToken(code string) (AccessToken, error)
从授权码得到访问令牌
func (*Authenticator) GetTokenInfo ¶
func (auth *Authenticator) GetTokenInfo(token string) (AccessTokenInfo, error)
得到访问令牌对应的信息
func (*Authenticator) Init ¶
func (auth *Authenticator) Init(redirectUri string, clientId string, clientSecret string) error
初始化结构体
在调用其它函数之前必须首先初始化。
func (*Authenticator) Revokeoauth2 ¶
func (auth *Authenticator) Revokeoauth2(token string) error
解除访问令牌的授权
type ErrorString ¶
type ErrorString struct {
S string
}
func (*ErrorString) Error ¶
func (e *ErrorString) Error() string
type Params ¶
type Params map[string]interface{}
Params类型用来表达微博API的JSON输入参数。注意:
- Params不应当包含访问令牌(access_token),因为它已经是Call和Upload函数的参数
- 在Upload函数中,Params参数不应当包含pic参数,上传的图片内容和类型应当通过reader和imageFormat指定
type Status ¶
type Status struct { Created_At string Id int64 Mid string Text string Idstr string Source string Favorited bool Trucated bool In_Reply_To_Status_Id string In_Reply_To_User_Id string In_Reply_To_Screen_Name string Thumbnail_Pic string Bmiddle_Pic string Original_Pic string Geo *Geo User *User Retweeted_Status *Status Reposts_Count int Comments_Count int Attitudes_Count int Mlevel int Visible *Visible Pic_Urls []*Pic_Url }
type User ¶
type User struct { Id int64 Idstr string Screen_Name string Name string Province string City string Location string Description string Url string Profile_Image_Url string Profile_Url string Domain string Weihao string Gender string Followers_Count int Friends_Count int Statuses_Count int Favourites_Count int Created_At string Following bool Allow_All_Act_Msg bool Geo_Enabled bool Verified bool Verified_Type int Remark string Status *Status Allow_All_Comment bool Avatar_Large string Verified_Reason string Follow_Me bool Online_Status int Bi_Followers_Count int Lang string }
type Weibo ¶
type Weibo struct {
// contains filtered or unexported fields
}
Weibo结构体定义了微博API调用功能
func (*Weibo) Call ¶
func (weibo *Weibo) Call(method string, httpMethod string, token string, params Params, response interface{}) error
调用微博API
该函数可用来调用除了statuses/upload(见Upload函数)和微博授权(见Authenticator结构体)外的所有微博API。
输入参数
method API方法名,比如 "/statuses/user_timeline" 又如 "comments/show" httpMethod HTTP请求方式,只能是"get"或者"post"之一,否则出错 token 用户授权的访问令牌 params JSON输入参数,见Params结构体的注释 response API服务器的JSON输出将被还原成该结构体
当出现异常时输出非nil错误
func (*Weibo) Upload ¶
func (weibo *Weibo) Upload(token string, params Params, reader io.Reader, imageFormat string, response interface{}) error
调用/statuses/upload发带图片微博
输入参数
token 用户授权的访问令牌 params JSON输入参数,见Params结构体的注释 reader 包含图片的二进制流 imageFormat 图片的格式,比如 "jpg" 又如 "png" response API服务器的JSON输出将被还原成该结构体
当出现异常时输出非nil错误
type WeiboError ¶
func (WeiboError) Error ¶
func (e WeiboError) Error() string
Click to show internal directories.
Click to hide internal directories.