func sync(name string, user *config.User) { if user.Enabled { weibo_account := user.GetAccount("tsina") twitter_account := user.GetAccount("twitter") posts := Timeline(weibo_account.Name, user.Last_weibo_id) oauth_user := oauth1a.NewAuthorizedConfig(twitter_account.Oauth_token_key, twitter_account.Oauth_token_secret) client := twittergo.NewClient(twitter_config, oauth_user) 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 := Tweet(client, post.Text) log.Println(weibo_account.Name, post.Text, tweet) if err != nil { log.Println("[error]", tweet, err) } } } } }
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) } } } } }