Skip to content

Commit

Permalink
Retrieve the search metadata along with the statues
Browse files Browse the repository at this point in the history
Signed-off-by: aditya <dev@chimeracoder.net>
  • Loading branch information
aswin authored and ChimeraCoder committed Dec 24, 2014
1 parent c2d27e7 commit 415ee7d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions search.go
Expand Up @@ -4,13 +4,23 @@ import (
"net/url"
)

type searchResponse struct {
Statuses []Tweet
type SearchMetadata struct {
CompletedIn float32 `json:"completed_in"`
MaxId int64 `json:"max_id"`
MaxIdString string `json:"max_id_str"`
Query string `json:"query"`
RefreshUrl string `json:"refresh_url"`
Count int `json:"count"`
SinceId int64 `json:"since_id"`
SinceIdString string `json:"since_id_str"`
}

func (a TwitterApi) GetSearch(queryString string, v url.Values) (timeline []Tweet, err error) {
var sr searchResponse
type SearchResponse struct {
Statuses []Tweet `json:"statuses"`
Metadata SearchMetadata `json:"search_metadata"`
}

func (a TwitterApi) GetSearch(queryString string, v url.Values) (sr SearchResponse, err error) {
v = cleanValues(v)
v.Set("q", queryString)

Expand All @@ -21,6 +31,5 @@ func (a TwitterApi) GetSearch(queryString string, v url.Values) (timeline []Twee
// Otherwise this will happen before the responses have been written
resp := <-response_ch
err = resp.err
timeline = sr.Statuses
return timeline, err
return sr, err
}

0 comments on commit 415ee7d

Please sign in to comment.