Facebook 图表 API 很慢
我正在这样做:
<?php echo json_decode(file_get_contents("http://graph.facebook.com/?id=8083675473"))->likes; ?>
有时需要 0.2 秒,有时需要 30 秒。问题是此页面的加载时间: http://graph.facebook.com/?id=8083675473 。
现在我想知道为什么有时它很慢。也许 Facebook 对我可以提出的请求数量有限制?
我只想在某个地方显示喜欢的数量,在不减慢整个页面速度的情况下检索它的最佳方法是什么?
我尝试通过ajax加载内容,但它不起作用,因为它是跨站点请求。
i am doing this :
<?php echo json_decode(file_get_contents("http://graph.facebook.com/?id=8083675473"))->likes; ?>
Sometimes, it takes .2 seconds, sometimes it takes 30 seconds. The problem is the load time of this page: http://graph.facebook.com/?id=8083675473.
Now i wonder why sometimes it is slow. Maybe facebook has limitations on the number of request i can make ?
I just want to show the number of like somewhere, what is the best way to retrieve it without slowing down the whole page?
I tried to load the content by ajax, but it does not work since it is a cross site request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,但是如果达到配额,你甚至无法获取任何数据
本地缓存,即从facebook获取结果,
并将其写入磁盘文件/数据库/memcache,
随后,您将不再需要从 facebook 获取数据
以保持数据新鲜度,您应该定期(安排)更新缓存
Yes, but if you reach the quota, you can not even getting any data
Cache locally, that's mean get the results from facebook,
and write it to disk-file/database/memcache,
subsequently, you will be no longer require to fetch the data from facebook
in order to keep the data freshness, you should periodically (schedule) to update the cache