Facebook和Symfony 1.4的问题

时间:2012-02-14 16:53:53

标签: facebook symfony-1.4 facebook-timeline

新Facebook和Symfony 1.4开发人员存在一些问题。

首先,我遇到了将“添加到时间轴”按钮显示在我需要它的页面上的问题。我的网站似乎显示Facebook加载图像,然后在明显加载后没有显示按钮。我查看了许多不同的站点(包括Open Graph的FB教程),所有人都说将脚本放在开始的body标签之后。我把它放在我的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是否在视图页面中没有看到某些内容。请注意,我还没有为Open Graph设置应用程序的操作和对象,此时发布到时间轴不是我关注的问题。对新手的任何想法或建议?

1 个答案:

答案 0 :(得分:0)

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

  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
  });