Facebook API Friends_get 非常慢

发布于 2024-08-30 04:55:46 字数 496 浏览 2 评论 0原文

我有一个在 iFrame 模式下运行的 PHP 应用程序。我正在 标记内渲染 。它位于一个 PHP 文件内,该文件调用一个函数,该函数使用 $facebook->api_client->friends_get(); 获取用户 ID 列表。多朋友选择器渲染得很好,但是,当我不注释friend_get()调用时,页面加载需要15-20秒(通过Firebug确认)!目标是通过构建一个不显示的用户 ID 列表来限制选择器中显示的用户数量,以供好友选择器的 except_ids 参数使用。由于它是“exclude_ids”而不是“include_ids”,我想不出一种方法来绕过这个 api 调用。在我看来,我必须采取一些措施来使 api 调用更快,因为我见过加载速度更快的好友选择器。

I have a PHP application running in iFrame mode. I am rendering an <fb:multi-friend-selector condensed="true"> inside of <fb:serverfbml> tags. This is inside a PHP file that calls a function that gets a list of user IDs using $facebook->api_client->friends_get();. The multi-friend selector renders just fine, but, when I leave the friend_get() call uncommented, the page takes between 15-20 seconds to load (confirmed with Firebug)! The goal is to limit the number of users displayed in the selector by building a list of user ids not to display, for use in the friend selector's exclude_ids parameter. And since it's "exclude_ids" and not "include_ids", I can't think of a way of getting around this api call. It seems to me there must be something I can do to make the api call faster, because I've seen friend selectors that load much more quickly.

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

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

发布评论

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

评论(1

心的位置 2024-09-06 04:55:46

经过一个多月的努力,我发现了一个相当可行的解决方法。对于您发出的任何 AJAX 请求,PHP API 调用的运行速度都会极其缓慢。这可能与 Facebook 参数缺失或其他类似的废话有关。

解决方法如下:不要从通过 AJAX 调用的 PHP 文件中调用 Facebook API 函数,而是确保将对 Facebook API 的所有 PHP 调用隔离到首次加载应用程序时加载的索引文件。将返回的值保存到会话变量中,现在您可以在后续进行的任何 AJAX 调用中加载这些值。

After over a month of ripping my hair out over this issue, I discovered a fairly feasible workaround. The PHP API calls will work extremely slowly from any AJAX requests you make. This likely has something to do with Facebook parameters being missing, or some other such nonsense.

The workaround works like this: instead of calling the Facebook API function from the PHP file being called via AJAX, make sure you isolate all PHP calls to the Facebook API to the index file loaded when the app is first loaded. Save the returned values into a session variable, and you can now load those values in whatever subsequent AJAX calls you make.

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