简体   繁体   English

Ruby Twitter 应用

[英]Ruby Twitter Applications

I'm using https://github.com/jnunemaker/twitter to tweet to a users twitter when they post on their blog running on ROR.当用户 twitter 在 ROR 上运行的博客上发帖时,我正在使用https://github.com/jnunemaker/twitter向用户发送推文。 .eg 。例如

Tweet: "I just posted a blog - 'I love ruby on rails' http://link-to-blog.com "推文:“我刚刚发布了一个博客 - '我喜欢 ruby on rails' http://link-to-blog.com

My question is, as I'm making many sites for different people do I have to create a new twitter developer application, with individual consumer keys & secrets, for each blog or is there a way to use the same twitter application?我的问题是,当我为不同的人创建许多网站时,我是否必须为每个博客创建一个新的 twitter 开发人员应用程序,其中包含个人消费者密钥和秘密,或者有没有办法使用相同的 twitter 应用程序?

Thanks,谢谢,

Alex亚历克斯

You technically can use the same application in a variety of websites.从技术上讲,您可以在各种网站中使用相同的应用程序。 Just use the keys/tokens twitter gives you in all your sites.只需使用 twitter 在所有站点中为您提供的密钥/令牌。

Nonetheless, this is a bad practice, since twitter will not be accounting your accesses to the API from the pages that are not the one you specify in the Callback URL.尽管如此,这是一种不好的做法,因为 twitter 不会记录您从不是您在回调 ZE6B391A8D2C4D45902A23A8B6585703D 中指定的页面的页面对 API 的访问 Furthermore, your users will return to that (and only to that) page that you specified in the callback URL , which can be very misleading for those that are in other site.此外,您的用户将返回到您在回调 URL 中指定的那个(并且仅那个)页面,这对于其他站点中的用户来说可能会非常误导。

And finally the most important reasons are the following two:最后最重要的原因有以下两个:

You'll get to the request limit quicker than if you had several applications与拥有多个应用程序相比,您将更快地达到请求限制

You'll get to the user limit quicker than if you had several applications与拥有多个应用程序相比,您将更快地达到用户限制

The limits that twitter manages are not very big so I can tell you that the twitter functionalities won't work if you get a good peak of visits (happened to me twice). twitter 管理的限制不是很大,所以我可以告诉您,如果您获得良好的访问高峰(发生在我身上两次),twitter 功能将不起作用。 Or they may not work if you're site receives a lot of visits at a certain time.或者,如果您的网站在特定时间收到大量访问,它们可能无法正常工作。 No matter if your cache your API or not, you'll end up filling the limit.无论您是否缓存 API,您最终都会达到限制。


Here is the twitter documentation about this:这是关于此的 twitter 文档:

Caching.缓存。 We recommend that you cache API responses in your application or on your site if you expect high-volume usage.如果您期望大量使用,我们建议您在应用程序或站点中缓存 API 响应。 For example, don't try to call the Twitter API on every page load of your hugely popular website.例如,不要尝试在您非常受欢迎的网站的每个页面加载时调用 Twitter API。 Instead, call our API once a minute and save the response to your local server, displaying your cached version on your site.相反,每分钟调用一次我们的 API 并将响应保存到您的本地服务器,在您的站点上显示您的缓存版本。 Refer to the Terms of Service for specific information about caching limitations.有关缓存限制的具体信息,请参阅服务条款。

Rate limiting by active user.活跃用户的速率限制。 If your site keeps track of many Twitter users (for example, fetching their current status or statistics about their Twitter usage), please consider only requesting data for users who have recently signed in to your site.如果您的网站跟踪许多 Twitter 用户(例如,获取他们的当前状态或关于他们的 Twitter 使用情况的统计数据),请考虑仅请求最近登录到您网站的用户的数据。 Scale your use of the API with the number of users you have.根据您拥有的用户数量扩展您对 API 的使用。 When using OAuth to authenticate requests with the API, the rate limit applied is specific to that user_token.当使用 OAuth 通过 API 验证请求时,应用的速率限制特定于该 user_token。 This means, every user who authorizes your application to act on their behalf, has their own bucket of API requests for you to use.这意味着,每个授权您的应用程序代表他们行事的用户都有自己的 API 请求桶供您使用。

Request only what you need, and only when you need it.只请求你需要的东西,并且只在你需要的时候。 For example, polling the REST API looking for new data is inefficient for both your application, and the Twitter API.例如,轮询 REST API 以查找新数据对于您的应用程序和 Twitter ZDB94644238D083A14FZ 都效率低下。 Instead consider using one of the Streaming APIs as a signal of when to make REST API requests.而是考虑使用其中一个流 API 作为何时发出 REST API 请求的信号。


If you have any question, don't hesitate to comment below.如果您有任何问题,请不要犹豫,在下面发表评论。 I had terrible experiences with this when my site got mentioned by a few important twitter accounts当我的网站被一些重要的 twitter 帐户提及时,我的经历很糟糕

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

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