Facebook 报价应用程序错误

发布于 2024-08-28 18:06:57 字数 1317 浏览 3 评论 0原文

如何编写 Facebook 报价应用程序,从 PHP/MySQL 页面获取数据并随机生成报价?我已经开发了一个,但它使用 FBML 不支持的 jQuery,并且由于我想要配置文件选项卡,所以我宁愿使用 FBML 而不是 iframe。

如何在不使用 jQuery 或使用 FBJS 的情况下做到这一点?

<!DOCTYPE html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="css/jquote.css" />

        <!--<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script>-->

        <script type="text/javascript" src="fbjqry/utility.js"></script>
        <script type="text/javascript" src="fbjqry/fjqry.js"></script>
        <script type="text/javascript">
            // On page load, fill the box with content.
            $(document).ready(function() {
                $("#quoteContainer").load("quote.php");
            });

            var auto_refresh = setInterval(
            function ()
            {
                $('#quoteContainer').load('quote.php');
            }, 5000); // refresh every 10000 milliseconds
        </script>

    </head>

    <div id="wrapper">
        <div class="header">&nbsp;Quote of the Day</div>
        <div id="quoteContainer">
        </div>
    </div>
</html>

How do I code a Facebook quote application taking its data from PHP/MySQL page generating quotes randomly? I've already developed one, but it's using jQuery which FBML doesn't support and since I'd like the profile tab I'd rather go for FBML instead of iframe.

How to do this without jQuery or using FBJS?

<!DOCTYPE html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="css/jquote.css" />

        <!--<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script>-->

        <script type="text/javascript" src="fbjqry/utility.js"></script>
        <script type="text/javascript" src="fbjqry/fjqry.js"></script>
        <script type="text/javascript">
            // On page load, fill the box with content.
            $(document).ready(function() {
                $("#quoteContainer").load("quote.php");
            });

            var auto_refresh = setInterval(
            function ()
            {
                $('#quoteContainer').load('quote.php');
            }, 5000); // refresh every 10000 milliseconds
        </script>

    </head>

    <div id="wrapper">
        <div class="header"> Quote of the Day</div>
        <div id="quoteContainer">
        </div>
    </div>
</html>

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

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

发布评论

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

评论(1

网白 2024-09-04 18:06:59

这是一个相当广泛的问题,但基本上 Facebook 有两种选择。您可以创建一个 FBML 应用程序,并将客户端脚本限制为 FBJS,或者您可以创建一个 iframe 应用程序,并利用您想要的任何 Javascript 库。

中间解决方案是使用 标记将 iframe 放入 FBML 页面中。 iframe 允许您使用完整的 Javascript,但当然您不能使用 iframe 内部的代码修改 iframe 外部的任何内容。它可能是一个很好的工具,你只需要正确设计你的 UI 即可。

您提到您使用 JQuery,但您并没有真正说明用途。如果您担心 AJAX 功能,FBJS 提供了该功能。如果您想要奇特的效果,那么您可能会不走运,因为 FBJS 的限制可能很大。

另一件需要记住的事情是,配置文件选项卡有自己的 URL,因此它们可以指向与主应用程序完全不同的代码。例如,如果您的主应用程序由 http://yourapp.com 提供,则在开发者设置中您可以设置“个人资料”选项卡位于 http://yourapp.com/profiletab。您没有理由不提供 iframe 应用程序作为主应用程序,只需为“配置文件”选项卡编写一些 FBML 输出即可。

That's a pretty broad question, but basically you have two options with Facebook. You can make an FBML application, and have your client-side scripting limited to FBJS, or you can make an iframe application, and utilize whatever Javascript libraries you want.

The intermediate solution is to put iframes in your FBML pages using the <fb:iframe> tag. The iframes will let you use full Javascript, but of course you can't modify anything outside the iframe using code from inside it. It can be a good tool though, you just have to design your UI properly.

You mention that you use JQuery, but you don't really say what for. If you're worried about AJAX functionality, FBJS provides that. If you want fancy effects, then you might be out of luck, as FBJS can be pretty limiting.

Another thing to keep in mind is that profile tabs get their own URL, so they can be pointed to completely separate code than the main application. For example, if your main app is served from http://yourapp.com, in the Developer settings you can set the Profile Tab to be at http://yourapp.com/profiletab. There's no reason you couldn't serve out an iframe app as the main application, and just code up some FBML output for the Profile Tab.

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