社交媒体源 - 客户端或服务器端请求?

发布于 2024-10-31 17:18:15 字数 306 浏览 0 评论 0原文

我很好奇其他开发人员在将 Twitter、Facebook 和其他此类提要内容集成到网站时会做什么。您是在客户端还是服务器端发出这些请求并处理所有事情?似乎有许多 jquery 插件可以处理简单集成的类型,我倾向于为大多数网站做这些事情,例如 3 个最新的帖子。

以前,我使用 PHP(Twitter 最近切换到 openauth 后集成变得更加复杂)从 twitter、博客等获取内容,但我想知道是否真的需要这样做,因为它可以非常简单地完成使用 JavaScript。显然,如果未启用 JavaScript,则提要将不会显示。

有兴趣听听人们在这种情况下会做什么!

I'm curious about what other developers do when integrating twitter, facebook and other such feed content on to a site. Do you make these requests and handle everything on the client or server side? It seems that there are a number of jquery plugins out there which handle the type of simple integrations which i tend to have to do for most sites, e.g 3 latest posts.

Previously, I was using PHP (Twitter became more complicated to integrate recently when it switched to openauth) to get content from twitter, blogger etc, but i'm wondering if there is any real need to do this when it can be done very simply with javascript. Obviously, if javascript isn't enabled then the feeds wouldn't display.

Interested to hear what people do in this situation!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

给妤﹃绝世温柔 2024-11-07 17:18:15

我倾向于直接从客户端代码连接到提要,除非我正在做一些复杂的事情,需要额外的验证或者想要缓存提要的结果。

基本原理是,如果您在服务器上抓取提要,则需要两次下载数据 - 一次从 API 服务器到您的服务器,一次从您的服务器到 - 而直接从客户端的 API 抓取数据代码仅产生单个 HTTP 请求,因此可以说加载速度更快。

当然,如果您有大量流量,第三方服务往往会进行速率限制,这意味着您可能必须研究服务器端缓存才能可靠地向访问者提供内容。

I tend to hook directly into the feeds from client-side code, unless I'm doing something complicated, need additional validation or would like to cache the results of the feed.

The rationale is that if you grab the feeds on the server, you have two download the data twice - once from the API server to your server, and once from your server to the - whereas grabbing it directly from the API in your client-side code only results in a single HTTP request, so should arguably load quicker.

Of course, if you've got a lot of traffic, third-party services tend to rate-limit, which means you might have to look into server-side caching to be able to reliably serve the content to your visitors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文