func main() { flag.Parse() t := twitter.Twitter{ ConsumerKey: "YOUR_CONSUMER_KEY", ConsumerSecret: "YOUR_CONSUMER_SECRET", OAuthToken: "YOUR_OAUTH_TOKEN", OAuthTokenSecret: "YOUR_OAUTH_TOKEN_SECRET", } str := strings.Join(flag.Args(), " ") for { tweet, err := t.Tweet(str) if err != nil { fmt.Println(err.Error()) return } time.Sleep(time.Duration(timeout) * time.Second) _, err = t.Destroy(tweet.Id) if err != nil { fmt.Println(err.Error()) return } } }
func sync(name string, user *config.User) { if user.Enabled { weibo_account := user.GetAccount("tsina") twitter_account := user.GetAccount("twitter") posts := Timeline(ACCESS_TOKEN, weibo_account.Name, user.Last_weibo_id) t := twitter.Twitter{ ConsumerKey: config.Twitter_ConsumerKey, ConsumerSecret: config.Twitter_ConsumerSecret, OAuthToken: twitter_account.Oauth_token_key, OAuthTokenSecret: twitter_account.Oauth_token_secret, } for i := len(posts) - 1; i >= 0; i-- { post := posts[i] if post.Id > user.Last_weibo_id { user.Last_weibo_id = post.Id tweet, err := t.Tweet(post.Text) log.Println(weibo_account.Name, post.Text) if err != nil { log.Println("[error]", tweet, err) } } } } }