Facebook 和 Symfony 1.4 的问题

发布于 2025-01-05 21:59:45 字数 1773 浏览 0 评论 0原文

新的 Facebook 和 Symfony 1.4 开发人员有几个问题。

首先,我在让“添加到时间轴”按钮出现在我需要的页面上时遇到问题。我的网站似乎显示 Facebook 加载图像,然后在明显加载后不显示任何按钮。我浏览了许多不同的网站(包括 Open Graph 的 FB 教程),都说将脚本放置在开始正文标记之后。我已将其放置在我的layout.php 文件中,这样我就不必将其放置在多个位置:

layout.php

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#">
....
<body>
    <div id="fb-root"></div>
    <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId      : 'APP_ID',
                status     : true, 
                cookie     : true,
                xfbml      : true,
                oauth      : true
            });
        };

        (function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=APP_ID";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>
    <div id="container">

我已经在适当的位置替换了 APP_ID 并将“添加到时间轴”按钮放置在视图中:

viewSuccess.php

<?php // Facebook Post-to-Timeline Button for this user's created recipe ?>
<?php if($recipe->getUserId() == sfUserTools::getConnectedUser()->getId()): ?>
    <fb:add-to-timeline show-faces="false" mode="button"></fb:add-to-timeline>
<?php endif ?>

我不确定是否是 JSSDK 脚本放置位置的问题,或者 Symfony 是否在视图页面中没有看到某些内容。请注意,我还没有为开放图谱设置我们的应用程序的操作和对象,目前我不关心发布到时间线。对新手有什么想法或建议吗?

New Facebook and Symfony 1.4 developer with a couple of issues.

First off, I am having an issue with getting the Add to Timeline button to appear on my page where I need it. My site seems to show a Facebook loading image, then after the apparent loading no button is displayed. I've looked around at many different sites (including the FB tutorial for Open Graph), all saying to place the scripts after the opening body tag. I have placed it in my layout.php file so that I do not have to put it in multiple places:

layout.php

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#">
....
<body>
    <div id="fb-root"></div>
    <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId      : 'APP_ID',
                status     : true, 
                cookie     : true,
                xfbml      : true,
                oauth      : true
            });
        };

        (function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=APP_ID";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>
    <div id="container">

I have already replaced APP_ID where appropriate and placed the Add to Timeline button in a view:

viewSuccess.php

<?php // Facebook Post-to-Timeline Button for this user's created recipe ?>
<?php if($recipe->getUserId() == sfUserTools::getConnectedUser()->getId()): ?>
    <fb:add-to-timeline show-faces="false" mode="button"></fb:add-to-timeline>
<?php endif ?>

I'm not sure if its an issue with where the JSSDK script is placed, or if Symfony is not seeing something in the view page. Note, I do not yet have our app's actions and objects setup for Open Graph, posting to the timeline is not my concern at this time. Any ideas or advice for a newbie?

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

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

发布评论

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

评论(1

木有鱼丸 2025-01-12 21:59:45

您是否尝试在 FB.init 上传递 access_token 或权限?

  FB.init({
    appId                : "<?php echo sfConfig::get('app_facebook_api_key') ?>",
    status               : true, // check login status
    cookie               : true, // enable cookies to allow the server to access the session
    xfbml                : false,  // parse XFBML
    perms                : 'read_stream, publish_stream',
    access_token         : "ACCESS_TOKEN_HERE",
    frictionlessRequests : true
  });

Did you try to pass the access_token or the perms on the FB.init ?

  FB.init({
    appId                : "<?php echo sfConfig::get('app_facebook_api_key') ?>",
    status               : true, // check login status
    cookie               : true, // enable cookies to allow the server to access the session
    xfbml                : false,  // parse XFBML
    perms                : 'read_stream, publish_stream',
    access_token         : "ACCESS_TOKEN_HERE",
    frictionlessRequests : true
  });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文