func FetchTimelinePage(c *oauth.Consumer, accessToken *oauth.AccessToken, page int) (tweets []interface{}, err error) { resp, err := c.Get( *flagURL, map[string]string{ "skip_user": "******", "count": "100", "include_rts": "1", "page": strconv.FormatInt(int64(page), 10), }, accessToken, ) if err != nil { log.Fatal(err) } defer resp.Body.Close() if err != nil { return nil, err } defer resp.Body.Close() tweets = make([]interface{}, 0) err = json.NewDecoder(resp.Body).Decode(&tweets) if err != nil { return nil, err } return tweets, nil }
func (user *TwUser) GetFromAPI(c *oauth.Consumer, at *oauth.AccessToken) os.Error { response, err := c.Get( TW_URL_VERIFY_CREDENTIAL, map[string]string{"skip_status": "true"}, at) if err != nil { return err } defer response.Body.Close() return user.Get(response.Body) }
func (tl *TwTimeLine) GetFromAPI(c *oauth.Consumer, at *oauth.AccessToken, count int, sinceId string) os.Error { params := map[string]string{"include_entities": "true", "count": strconv.Itoa(count)} if sinceId != "" && sinceId != "0" { params["since_id"] = sinceId } response, err := c.Get( TW_URL_HOME_TIMELINE, params, at) if err != nil { return err } defer response.Body.Close() return tl.Get(response.Body) }
func Tumblr(f File, ch chan File) { tumbUri, _ := url.Parse(tumbHost) p := f.Url.Path if len(p) == 0 || p == "/" { tok, err := OAuth() if err != nil { f.SendErr(ch, &err) return } cons := oauth.Consumer{HttpClient: HClient} for i := 0; ; i += 20 { resp, err := cons.Get(tumbHost+tumbFollowing, map[string]string{"offset": strconv.Itoa(i)}, tok) check(err) var fr followingResponse checkResponse(resp, &fr) for _, b := range fr.Blogs { bUri, err := url.Parse(b.Url) check(err) bUri.Path = bUri.Host ch <- File{Url: *bUri} } if i >= fr.Total_blogs { break } } } else { tok, _, err := Keychain(*tumbUri) if err != nil { f.SendErr(ch, &err) return } err = tumblrBlog(f, tok, ch) f.SendErr(ch, &err) } return }