本文整理汇总了Golang中github.com/ChimeraCoder/anaconda.TwitterApi类的典型用法代码示例。如果您正苦于以下问题:Golang TwitterApi类的具体用法?Golang TwitterApi怎么用?Golang TwitterApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TwitterApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetHomeTimeline
// 自分のTimelineを表示する。
func GetHomeTimeline(api *anaconda.TwitterApi, v url.Values) {
tweets, err := api.GetHomeTimeline(v)
check(err)
for _, tweet := range tweets {
PrintTweet(tweet)
}
}
开发者ID:honeybe,项目名称:code-sample,代码行数:8,代码来源:main.go
示例2: postImageTweet
func postImageTweet(api *anaconda.TwitterApi, gifFile string, t *anaconda.Tweet) error {
// Post
data, err := ioutil.ReadFile(gifFile)
if err != nil {
return err
}
mediaResponse, err := api.UploadMedia(base64.StdEncoding.EncodeToString(data))
if err != nil {
return err
}
v := url.Values{}
v.Set("media_ids", strconv.FormatInt(mediaResponse.MediaID, 10))
v.Set("in_reply_to_status_id", t.IdStr)
tweetString := fmt.Sprintf("@%s here are your fireworks", t.User.ScreenName)
_, err = api.PostTweet(tweetString, v)
if err != nil {
return err
} else {
// fmt.Println(result)
}
return nil
}
开发者ID:Kimau,项目名称:ProcJam15,代码行数:28,代码来源:main.go
示例3: PublishTweet
func PublishTweet(article *Article, replyToId string, api *anaconda.TwitterApi) (string, error) {
msg := twitterize(article)
_, err := api.PostTweet(msg, url.Values{
"in_reply_to_status_id": []string{replyToId},
})
return msg, err
}
开发者ID:jprobinson,项目名称:NYTPlusContextBot,代码行数:7,代码来源:twitter.go
示例4: fetchStats
// Fetch stats from Twitter and store it for display by the web interface.
func fetchStats(api *anaconda.TwitterApi) error {
handles := strings.Join(democrats, ",") + "," + strings.Join(republicans, ",")
users, err := api.GetUsersLookup(handles, url.Values{})
if err != nil {
return err
}
t := make([]TwitterInfo, len(users))
for i, u := range users {
t[i].Name = u.Name
t[i].Image = u.ProfileImageURL
t[i].Followers = u.FollowersCount
t[i].Tweets = u.StatusesCount
for _, d := range democrats {
if u.ScreenName == d {
t[i].Democrat = true
break
}
}
}
sort.Sort(ByFollowers(t))
stats.Put(t)
return nil
}
开发者ID:rapidloop,项目名称:followtheleader,代码行数:27,代码来源:main.go
示例5: fetchTwitterFriends
// Returns a slice with twitter ids of the given user's friends
func fetchTwitterFriends(screenName string, api *anaconda.TwitterApi) ([]string, error) {
if api == nil {
// Let's just pretend he has no friends, because we can't actually ask
// Twitter about it
return []string{}, nil
}
v := url.Values{}
v.Set("count", "100")
v.Set("cursor", "-1")
v.Set("screen_name", screenName)
friendsIds, err := api.GetFriendsIds(v)
if err != nil {
return nil, err
}
friends, err := api.GetUsersLookupByIds(friendsIds.Ids, url.Values{})
if err != nil {
return nil, err
}
var friendsNames []string
for _, friend := range friends {
friendsNames = append(friendsNames, friend.ScreenName)
}
return friendsNames, nil
}
开发者ID:WarCluster,项目名称:warcluster-server,代码行数:30,代码来源:auth.go
示例6: blockUser
// Block a user, and tweet a notification of why they were blocked
func blockUser(tweet anaconda.Tweet, ruleName string, cfg *Config, api *anaconda.TwitterApi) {
// Block the user from the main account
user, err1 := api.BlockUserId(tweet.User.Id, nil)
if err1 != nil {
log.Fatalf("Failed to block user: %s", err1)
}
// Let them know via the notification account
anaconda.SetConsumerKey(cfg.Auth2.ConsumerKey)
anaconda.SetConsumerSecret(cfg.Auth2.ConsumerSecret)
api2 := anaconda.NewTwitterApi(cfg.Auth2.AccessToken, cfg.Auth2.AccessTokenSecret)
// TODO: Make this work...
params := url.Values{}
params.Set("InReplyToStatusID", tweet.IdStr)
params.Set("InReplyToStatusIdStr", tweet.IdStr)
tweet2, err2 := api2.PostTweet("@"+user.ScreenName+
": Hi! You've been blocked by @"+cfg.Settings.MyScreenName+
". Reason: "+cfg.Settings.ReasonsURL+"#"+ruleName, params)
if err2 != nil {
log.Fatalf("Failed to notify blocked user: %s", err2)
}
// Display tweet in terminal
fmt.Println(">> " + tweet2.Text)
// Restore API to main account auth settings
anaconda.SetConsumerKey(cfg.Auth.ConsumerKey)
anaconda.SetConsumerSecret(cfg.Auth.ConsumerSecret)
}
开发者ID:denny,项目名称:MentionsManager,代码行数:32,代码来源:manager.go
示例7: FetchTweet
func FetchTweet(id int64, api *anaconda.TwitterApi) anaconda.Tweet {
tweet, err := api.GetTweet(id, nil)
if err != nil {
panic(err)
}
return tweet
}
开发者ID:if1live,项目名称:makina,代码行数:7,代码来源:fetch.go
示例8: checkForTweets
func checkForTweets(api anaconda.TwitterApi) error {
searchResult, err := api.GetHomeTimeline()
if err != nil {
log.Print("error fetching timeline: %v", err)
return err
}
//Assume that we haven't tweeted at each other more than 10 times since the last check
//Knowing us, this is a very bad assumption.
log.Printf("We have %d results", len(searchResult))
//Iterate over the tweets in chronological order (the reverse order from what is returned)
for i := len(searchResult) - 1; i >= 0; i-- {
tweet := searchResult[i]
if TweetMentionsATarget(tweet) {
if err := retweetAndLog(api, tweet); err != nil {
log.Print("error when retweeting %v", err)
continue
}
log.Print(tweet.Text)
} else {
//log.Printf("Skipping tweet %v", tweet.Text)
}
}
return nil
}
开发者ID:ChimeraCoder,项目名称:otterandjen,代码行数:25,代码来源:server.go
示例9: twitterHandler
func twitterHandler(api *anaconda.TwitterApi) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
re := regexp.MustCompile("(http|ftp|https)://([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-]*[\\[email protected]?^=%&/~+#-])?")
query := r.URL.Query().Get("q")
v := url.Values{}
//v.Set("f", "news")
v.Set("lang", "en")
v.Set("count", "100")
result, err := api.GetSearch(query, v)
if err != nil {
handleWebErr(w, err)
return
}
var results []string
for _, tweet := range result.Statuses {
results = append(results, re.ReplaceAllLiteralString(tweet.Text, ""))
}
msg, err := json.Marshal(results)
if err != nil {
handleWebErr(w, err)
return
}
w.Header().Set("Content-Type", "application/json")
fmt.Fprint(w, string(msg))
}
}
开发者ID:ohyeslk,项目名称:DisasterResponse,代码行数:35,代码来源:twitter.go
示例10: GenerateFireworkFor
func GenerateFireworkFor(api *anaconda.TwitterApi, t *anaconda.Tweet) error {
checkFile := MakeGifFilename(t.User.ScreenName, t.Id)
if Exists(checkFile) {
fmt.Println("Already Exsists")
return nil
}
v := url.Values{}
v.Set("screen_name", t.User.ScreenName)
v.Set("count", "30")
search_result, err := api.GetUserTimeline(v)
if err != nil {
return err
}
gifFile, e := genTwitterGif(search_result, t.User.ScreenName, t.Id)
if e != nil {
return e
}
if *live {
return postImageTweet(api, gifFile, t)
} else {
fmt.Println("Not live: ", live, t.User.ScreenName, gifFile)
}
return nil
}
开发者ID:Kimau,项目名称:ProcJam15,代码行数:29,代码来源:main.go
示例11: GetSearchStream
func (tc *TwitterController) GetSearchStream(api *anaconda.TwitterApi, query string) chan anaconda.Tweet {
c := make(chan anaconda.Tweet)
go func(chanNotify chan anaconda.Tweet) {
var since_id int64
for {
v := url.Values{}
v.Set("local", "ja")
v.Set("count", "20")
if since_id > 0 {
ssince_id := strconv.FormatInt(since_id, 10)
v.Set("since_id", ssince_id)
}
resp, err := api.GetSearch(query, v)
if err == nil {
for _, status := range resp.Statuses {
chanNotify <- status
if status.Id > since_id {
since_id = status.Id
}
}
} else {
log.Printf("An error occured while searching. err:%v", err)
}
time.Sleep(time.Second * 30)
}
}(c)
return c
}
开发者ID:harurock,项目名称:moja,代码行数:28,代码来源:twitter.go
示例12: ShowTimeline
// 指定したユーザのTweetを表示する。
func ShowTimeline(api *anaconda.TwitterApi, v url.Values, screenName string) {
v.Set("screen_name", screenName)
tweets, err := api.GetUserTimeline(v)
check(err)
for _, tweet := range tweets {
PrintTweet(tweet)
}
}
开发者ID:honeybe,项目名称:code-sample,代码行数:9,代码来源:main.go
示例13: updateStatus
func updateStatus(subject string, api anaconda.TwitterApi) bool {
_, err := api.PostTweet(subject, nil)
if err != nil {
fmt.Println("Posting Tweet failed! Error : ", err)
os.Exit(1)
}
return true
}
开发者ID:istanbul-coders,项目名称:monsterghost,代码行数:8,代码来源:tweet.go
示例14: updateTimeline
func updateTimeline(api *an.TwitterApi) []an.Tweet {
v := url.Values{}
home, err := api.GetHomeTimeline(v)
if err != nil {
fmt.Println("error: ", err)
}
return home
}
开发者ID:lovelaced,项目名称:spoon,代码行数:8,代码来源:twitter.go
示例15: getLatestTweets
func getLatestTweets(client *anaconda.TwitterApi, screenName string, length int) (tweets []anaconda.Tweet, err error) {
query := url.Values{}
query.Set("screen_name", screenName)
query.Set("count", fmt.Sprintf("%v", length))
query.Set("trim_user", "true")
query.Set("exclude_replies", "true")
query.Set("include_rts", "true")
return client.GetUserTimeline(query)
}
开发者ID:djui,项目名称:potd,代码行数:9,代码来源:twitter.go
示例16: Tweet
func Tweet(status string) (tweet anaconda.Tweet, err error) {
var client *anaconda.TwitterApi
if twitterClient != nil {
client = twitterClient
} else {
client = TwitterClient()
}
return client.PostTweet(status, url.Values{})
}
开发者ID:RockinTechBomb,项目名称:fx-devtools-bot,代码行数:9,代码来源:tweet.go
示例17: showTimeLine
func showTimeLine(api *anaconda.TwitterApi, v url.Values) {
tweets, err := api.GetHomeTimeline(v)
if err != nil {
panic(err)
}
for _, tweet := range tweets {
fmt.Println("tweet: ", tweet.Text)
fmt.Println("id: ", tweet.Id)
}
}
开发者ID:KazushiSakashita,项目名称:MAOUVS,代码行数:10,代码来源:test.go
示例18: PostTweets
func PostTweets(api *anaconda.TwitterApi, bts []BeetTweet, db *sql.DB) {
for _, bt := range bts {
//TODO: Psuedo random reminder messages. For fun, and not angering the twitter api.
_, err := api.PostTweet(fmt.Sprintf("@%s The number is %d.", bt.Name, bt.Hours), nil)
if err == nil {
query := fmt.Sprintf("UPDATE tweet SET NOTIFIED = true WHERE ID = %d;", bt.Id)
db.Query(query)
}
}
}
开发者ID:mrkplt,项目名称:you_ate_beets,代码行数:11,代码来源:beet_tweet.go
示例19: newTwitterStream
func newTwitterStream(conf *Config, api *anaconda.TwitterApi) *anaconda.Stream {
track, follow := conf.GetTweetFilter()
params := url.Values{}
params.Set("track", track)
params.Set("follow", follow)
stream := api.PublicStreamFilter(params)
return stream
}
开发者ID:kerwindena,项目名称:koma-bot,代码行数:12,代码来源:twitter.go
示例20: getMentions
// Get mentions
func getMentions(mentionsCount string, api *anaconda.TwitterApi) []anaconda.Tweet {
params := url.Values{}
params.Set("count", mentionsCount)
// TODO: Track tweet ID we checked up to last time, and check from there onwards
mentions, err := api.GetMentionsTimeline(params)
if err != nil {
log.Fatalf("Failed to get mentions: %s", err)
}
return (mentions)
}
开发者ID:denny,项目名称:MentionsManager,代码行数:14,代码来源:manager.go
注:本文中的github.com/ChimeraCoder/anaconda.TwitterApi类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论