简体   繁体   English

推特竞赛逻辑(Twitter)

[英]Tweet Contest logic ( Twitter )

Disclaimer: I have no Twitter API experience nor have I used Twitter until today 免责声明:直到今天我都没有Twitter API经验,也没有使用过Twitter

I've been given the task of creating a 'tweeting contest' - if anyone has Twitter API experience and/or has done this in the past, I would appreciate any useful tips that you may have. 我已经承担了创建“推特竞赛”的任务-如果任何人具有Twitter API经验和/或过去曾做过,我将不胜感激您可能拥有的任何有用技巧。

So the basic rules are that in order for a user to enter the contest, said user must follow the contest's twitter and must retweet with a specific message, such as 'just entered a contest for http://foo.com/contest '. 因此,基本规则是,为了使用户能够参加竞赛,该用户必须关注竞赛的Twitter,并且必须转发特定的消息,例如“刚刚参加了http://foo.com/contest竞赛”。

Questions: 问题:

  1. To get the entrants, I have to parse the rss feed of the contest, http://twitter.com/statuses/user_timeline/21586418.rss seems to only list the last few posts so I would probably have to interact with the Twitter API in order to get all messages. 为了获得参赛者,我必须解析比赛的RSS提要, http://twitter.com/statuses/user_timeline/21586418.rss似乎只列出了最近的几篇文章,所以我可能必须与Twitter API进行交互为了得到所有消息。 Can someone recommend documentation or a page that covers this? 有人可以推荐涵盖此内容的文档或页面吗?

  2. I'm not exactly sure if I should store the actual users in a local xml file or rely on querying the Twitter API, if I store them I would have a cache local copy of users... a database would be overkill and if I were to store them it would be better off in an xml file, right? 我不确定我应该将实际用户存储在本地xml文件中还是依靠查询Twitter API,如果我存储它们,那么我将缓存用户的本地副本...如果数据库过大,我是否可以将它们存储在xml文件中会更好,对吧?

  3. Related to #1, should I actually parse for the exact message which the user has to tweet, eg "just entered a contest", the exact string when I parse through the data feed of all the tweets? 与#1相关,当我解析所有推文的数据馈送时,我是否应该解析用户必须发的确切消息(例如,“刚参加比赛”)的确切字符串? Or is there some sort of tagging system I can use? 还是我可以使用某种标记系统?

  4. Related to #1, I would have to determine whether the user is a follower or not, so I can't determine that by parsing an entry/tweet, I would have to query the user's id and grab statistics from the people he/she follows? 与#1相关,我将不得不确定用户是否是关注者,因此我无法通过解析条目/推文来确定用户ID并从他/她的人那里获取统计信息跟随?

You could search for the URL, but the best approach would be to use a hashtag : 您可以搜索URL,但是最好的方法是使用井号

just entered #supercoolcontest for http://foo.com/contest

You can search for incidences of #supercoolcontest which contain the required contest URL or whatever other keywords you might want. 您可以搜索#supercoolcontest事件,其中包含所需的比赛URL或您可能想要的其他任何关键字。 This will ensure users don't have to be text-precise when retweeting, and also gives people a way to talk about the contest in a general way that is trackable. 这样可以确保用户在转推时不必精确输入文字,还可以让人们以一种可追踪的一般方式谈论比赛。

You can pull all tweets with a hashtag by using the search API : 您可以使用搜索API提取所有带有主题标签的tweet:

http://search.twitter.com/search.json?q=%23supercoolcontest

This is probably the most efficient approach, since you are guaranteed to only pull the tweets you're interested in, instead of n tweets from n users, only a tiny fraction of which has anything to do with you. 这可能是最有效的方法,因为可以保证只拉出您感兴趣的tweet,而不是来自n个用户的n条tweet,其中只有一小部分与您有关。

Every time you scrape that API feed (every n minutes), insert new unique users. 每次您抓取该API供稿时(每隔n分钟),请插入一个新的唯一用户。 I'd use a database - not hard or time consuming to stand something up with a table or two. 我会使用数据库-用一两个表站立起来并不困难或很费时间。 Easier to query against later. 以后更容易查询。

To answer your last question, you do need to make a separate API call to determine if a given user follows another user. 要回答您的最后一个问题,您确实需要进行单独的API调用,以确定给定用户是否跟随另一个用户。

I know this is an old question and is probably not relevant to meder anymore, nonetheless I want to comment that now there is another way to solve this problem using Twitter's Streamming API http://dev.twitter.com/pages/streaming_api the advantage of this approach is that you are telling twitter to send all the tweets that accomplish some conditions right when they are generated. 我知道这是一个老问题,可能不再与混战相关,不过我想评论一下,现在有了使用Twitter的Streaming API http://dev.twitter.com/pages/streaming_api解决此问题的另一种方法这种方法的意思是,您要告诉Twitter在生成它们时立即发送完成某些条件的所有Tweet。

With the search API you need to poll twitter for new tweets all the time and there is a bigger chance that some of them will be missing from the search results; 使用搜索API,您需要一直在Twitter上轮询新的tweet,并且有更大的机会在搜索结果中丢失其中的一些tweet。 meanwhile with the streaming API you keep an open connection to twitter and process the tweets as they come, Twitter won't guarantee that you will get all the tweets that meet the conditions, but from my experience the risk is much lower. 同时,使用流式API,您可以保持与Twitter的开放连接并在Twitter出现时处理这些Twitter消息,Twitter不能保证您将获得所有符合条件的Twitter消息,但是根据我的经验,风险要低得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM