weibo

package
v0.0.0-...-c8c3dd5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.

func Int64

func Int64(v int) *int64

Int is a helper routine that allocates a new int64 value to store v and returns a pointer to it, but unlike Int64 its argument value is an int.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent used when communicating with the Weibo API.
	UserAgent string

	// Services used for talking to different parts of the Weibo API.
	Statuses *StatusesService
	// contains filtered or unexported fields
}

A Client manages communication with the Weibo API.

func NewClient

func NewClient(accessToken string) *Client

NewClient returns a new Weibo API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occured. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlString string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type ErrorResponse

type ErrorResponse struct {
	Response   *http.Response // HTTP response that caused this error
	RequestURL string         `json:"request"`    // request on which the error occured
	ErrorCode  int            `json:"error_code"` // error_code
	Message    string         `json:"error"`      // error message
}

An Error Response reports one or more errors caused by an API request.

Weibo API docs: http://open.weibo.com/wiki/Error_code

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type ListOptions

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Page int `url:"page,omitempty"`

	// For paginated result sets, the number of results to include per page.
	PerPage int `url:"count,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type Response

type Response struct {
	*http.Response
}

Response is a Weibo API response. This wraps the standrad http.Response returned from Weibo. For future use, maybe.

type Status

type Status struct {
	CreatedAt      *string  `json:"created_at,omitempty"`
	ID             *int64   `json:"id,omitempty"`
	MID            *string  `json:"mid,omitempty"`
	IDStr          *string  `json:"idstr,omitempty"`
	Text           *string  `json:"text,omitempty"`
	Source         *string  `json:"source,omitempty"`
	Favorited      *bool    `json:"favorited,omitempty"`
	Truncated      *bool    `json:"truncated,omitempty"`
	User           *User    `json:"user,omitempty"`
	RepostsCount   *int     `json:"reposts_count,omitempty"`
	CommentsCount  *int     `json:"comments_count,omitempty"`
	AttitudesCount *int     `json:"attitudes_count,omitemtpy"`
	Visible        *Visible `json:"visible,omitempty"`
}

Status represents a Weibo's status.

type StatusListOptions

type StatusListOptions struct {
	UID        string `url:"uid,omitempty"`
	ScreenName string `url:"screen_name,omitempty"`
	SinceID    string `url:"since_id,omitempty"`
	MaxID      string `url:"max_id,omitempty"`
	ListOptions
}

StatusListOptions specifies the optional parameters to the StatusService.UserTimeline method.

type StatusRequest

type StatusRequest struct {
	Status      *string  `url:"status"`
	Visible     *int     `url:"visible,omitempty"`
	ListID      *int     `url:"list_id,omitempty"`
	Lat         *float64 `url:"lat,omitempty"`
	Long        *float64 `url:"long,omitempty"`
	Annotations *string  `url:"annotations,omitempty"`
	RealIP      *string  `url:"rip,omitempty"`
}

StatusRequest represetns a request to create a status.

type StatusesService

type StatusesService struct {
	// contains filtered or unexported fields
}

StatusesService handles communication with the Status related methods of the Weibo API.

Weibo API docs: http://open.weibo.com/wiki/%E5%BE%AE%E5%8D%9AAPI

func (*StatusesService) Create

func (s *StatusesService) Create(opt *StatusRequest) (*Status, *Response, error)

Create a Weibo Status.

Weibo API docs: http://open.weibo.com/wiki/2/statuses/update

func (*StatusesService) UserTimeline

func (s *StatusesService) UserTimeline(opt *StatusListOptions) (*Timeline, *Response, error)

Timeline of a user. Passing the empty string will return timeline for the authenticated user.

Weibo API docs: http://open.weibo.com/wiki/2/statuses/user_timeline

func (*StatusesService) UserTimelineIDs

func (s *StatusesService) UserTimelineIDs(opt *StatusListOptions) (*TimelineIDs, *Response, error)

Timeline IDs of a user. Passing the empty string will return timeline for the authenticated user.

Weibo API docs: http://open.weibo.com/wiki/2/statuses/user_timeline

type Timeline

type Timeline struct {
	Statuses       []Status `json:"statuses,omitempty"`
	TotalNumber    *int     `json:"total_number,omitempty"`
	PreviousCursor *int     `json:"previous_cursor,omitempty"`
	NextCursor     *int     `json:"next_cursor,omitempty"`
}

Timeline represents Weibo statuses set.

type TimelineIDs

type TimelineIDs struct {
	StatusesIDs    []string `json:"statuses,omitempty"`
	TotalNumber    *int     `json:"total_number,omitempty"`
	PreviousCursor *int     `json:"previous_cursor,omitempty"`
	NextCursor     *int     `json:"next_cursor,omitempty"`
}

TimelineIDs represents Weibo statuses ids set.

type User

type User struct {
	ID               *int    `json:"id,omitempty"`
	ScreeName        *string `json:"screen_name,omitempty"`
	Name             *string `json:"name,omitempty"`
	Province         *string `json:"province,omitempty"`
	City             *string `json:"city,omitempty"`
	Location         *string `json:"location,omitempty"`
	Description      *string `json:"description,omitempty"`
	URL              *string `json:"url,omitempty"`
	ProfileImageUrl  *string `json:"profile_image_url,omitempty"`
	Domain           *string `json:"domain,omitempty"`
	Gender           *string `json:"gender,omitempty"`
	FollowersCount   *int    `json:"followers_count,omitempty"`
	FriendsCount     *int    `json:"friends_count,omitempty"`
	StatusesCount    *int    `json:"statuses_count,omitempty"`
	FavouritesCount  *int    `json:"favourites_count,omitempty"`
	CreatedAt        *string `json:"created_at,omitempty"`
	Following        *bool   `json:"following,omitempty"`
	AllowAllActMsg   *bool   `json:"allow_all_act_msg,omitempty"`
	GeoEnabled       *bool   `json:"geo_enabled,omitempty"`
	Verified         *bool   `json:"verified,omitempty"`
	AllowAllComment  *bool   `json:"allow_all_comment,omitempty"`
	AvatarLarge      *string `json:"avatar_large,omitempty"`
	VerifiedReason   *string `json:"verified_reason,omitempty"`
	FollowMe         *bool   `json:"follow_me,omitempty"`
	OnlineStatus     *int    `json:"online_status,omitempty"`
	BiFollowersCount *int    `json:"bi_followers_count,omitempty"`
}

User represents a Weibo user.

type Visible

type Visible struct {
	VType  *int `json:"type,omitempty"`
	ListID *int `json:"list_id,omitempty"`
}

Visible represents visible object of a Weibo status.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL