Example #1
0
// 查询last_id以后的最新冒泡列表
// API: GET /api/social/tweet/last
func (s *TweetService) Last(params *operations.TweetsLastParams) ([]*models.TweetDTO, error) {
	apiReq := new(httputil.ApiRequest)
	params.WriteToRequest(apiReq, nil)

	req, err := s.client.NewRequest("GET", apiReq.GetPath(), nil)
	if err != nil {
		return nil, err
	}

	out := &operations.TweetsLastResponseBody{}
	_, err = s.client.Do(req, &out)
	return out.Data, err
}
Example #2
0
// 冒泡广场列表
// API: GET   /api/tweet/public_tweets
func (s *TweetService) PublicTweets(params *operations.PublicTweetsParams) ([]*models.TweetDTO, error) {
	apiReq := new(httputil.ApiRequest)
	params.WriteToRequest(apiReq, nil)

	req, err := s.client.NewRequest("GET", apiReq.GetPath(), nil)
	if err != nil {
		return nil, err
	}
	//	fmt.Println("req.RequestURI: "+req.RequestURI)

	out := &operations.PublicTweetsResponseBody{}
	_, err = s.client.Do(req, &out)
	return out.Data, err
}
Example #3
0
// 删除冒泡
// API: DELETE /api/social/tweet/{tweet_id}
func (s *TweetService) Delete(params *operations.TweetDeleteParams) (bool, error) {
	apiReq := new(httputil.ApiRequest)
	params.WriteToRequest(apiReq, nil)

	if err := apiReq.SetQueryParam("access_token", s.client.AccessToken); err != nil {
		return false, err
	}

	v := apiReq.GetFormValues()
	formBody := ioutil.NopCloser(strings.NewReader(v.Encode()))
	req, err := s.client.NewRequest("DELETE", apiReq.GetPath(), formBody)
	if err != nil {
		return false, err
	}
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	out := &operations.TweetDeleteResponseBody{}
	_, err = s.client.Do(req, &out)
	return out.Data, err
}