|
|
|
@ -1,8 +1,12 @@
|
|
|
|
|
package WorstCaptcha
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/kurrik/twittergo"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/kurrik/oauth1a"
|
|
|
|
|
"github.com/kurrik/twittergo"
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/url"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func NewTwitter(config Config) *twittergo.Client {
|
|
|
|
@ -18,3 +22,48 @@ func NewTwitter(config Config) *twittergo.Client {
|
|
|
|
|
|
|
|
|
|
return twittergo.NewClient(twitterConfig, user)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func DoSearch(client *twittergo.Client) *twittergo.SearchResults {
|
|
|
|
|
var (
|
|
|
|
|
err error
|
|
|
|
|
req *http.Request
|
|
|
|
|
resp *twittergo.APIResponse
|
|
|
|
|
results *twittergo.SearchResults
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Build search
|
|
|
|
|
query := url.Values{}
|
|
|
|
|
query.Set("q", "from:reverseocr")
|
|
|
|
|
query.Set("count", "20")
|
|
|
|
|
|
|
|
|
|
// Build URI
|
|
|
|
|
url := fmt.Sprintf("/1.1/search/tweets.json?%v", query.Encode())
|
|
|
|
|
|
|
|
|
|
// Prepare request
|
|
|
|
|
if req, err = http.NewRequest("GET", url, nil); err != nil {
|
|
|
|
|
fmt.Printf("Could not parse request: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sign and send request
|
|
|
|
|
if resp, err = client.SendRequest(req); err != nil {
|
|
|
|
|
fmt.Printf("Could not send request: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parse response
|
|
|
|
|
results = &twittergo.SearchResults{}
|
|
|
|
|
if err = resp.Parse(results); err != nil {
|
|
|
|
|
fmt.Printf("Problem parsing response: %v\n", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Print ratelimit data
|
|
|
|
|
if resp.HasRateLimit() {
|
|
|
|
|
fmt.Printf("Rate limit: %v\n", resp.RateLimit())
|
|
|
|
|
fmt.Printf("Rate limit remaining: %v\n", resp.RateLimitRemaining())
|
|
|
|
|
fmt.Printf("Rate limit reset: %v\n", resp.RateLimitReset())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
}
|
|
|
|
|