什么是通过PHP使用Twitter的API的最好方法? [英] What's the best way to use the Twitter API via PHP?

查看:136
本文介绍了什么是通过PHP使用Twitter的API的最好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个客户想我他们的Twitter流添加到他们的网站主页,使用内置在PHP自定义解决方案。

A client would like me to add their Twitter stream to their website homepage, using a custom solution built in PHP.

Twitter的API显然你可以把它每小时呼叫的数量有限,所以我不能自动平微博每当有人刷新我的客户的主页。

The Twitter API obviously has a limited number of calls you can make to it per hour, so I can't automatically ping Twitter every time someone refreshes my client's homepage.

客户端的网站是纯粹的时刻HTML等方面存在的没有数据库可用。因此,我的解决方案必须只需要PHP和本地文件系统(例如保存在它的一些数据的本地XML文件)。

The client's website is purely HTML at the moment and so there is no database available. My solution must therefore only require PHP and the local file system (e.g. saving a local XML file with some data in it).

因此​​,考虑到这有限的标准,什么是对我来说,访问Twitter的API的最佳方式 - 通过PHP - 没有击中在几分钟内我的API调用上限

So, given this limited criteria, what's the best way for me to access the Twitter API - via PHP - without hitting my API call limit within a few minutes?

推荐答案

这将是很容易,一旦你可以拉下一个时间表,并显示它,再加入一些基于文件的缓存它。

It will be quite easy, once you can pull down a timeline and display it, to then add some file-based-caching to it.

check age of cache
Is it more than 5 mins old?
    fetch the latest information
    regenerate the HTML for output
    save the finished HTML to disk
display the cached pre-prepared HTML

PEAR的Cache_Lite 将尽一切你需要的缓存层上。

PEAR's Cache_Lite will do all you need on the caching layer.

这篇关于什么是通过PHP使用Twitter的API的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆