Facebook iFrame 选项卡适用于我,但对其他人来说却显示为空白?

发布于 2024-12-19 12:38:56 字数 3472 浏览 1 评论 0原文

我正在尝试为 Facebook 页面创建一个自定义选项卡,它在 Firefox 和 Internet Explorer 8 中非常适合我,无论是页面上的选项卡还是直接链接,但对于其他人来说,它只是显示为空白。

我也是该页面的管理员,如果我尝试以其他人的身份登录,那么它对我来说也会变成空白。

这是我的代码:

require 'src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId' => 'xxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxx',
));

$user = $facebook->getUser();

if ($user) {
try {
    $likes = $facebook->api("/me/likes/PAGEID");
    if( !empty($likes['data']) )
    {
        ?>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('#fan').click(function() {
                $('#fan').animate({
                    opacity: 0.2,
                    width: 'auto',
                    height: 'auto'
                }, 1000, function() {
                    // Animation complete.
                    $('#fan').hide('slow');
                    $('#voucher').show('slow');
                });
            });
        });
        </script>

        <a href="#"><img id="fan" src="http://www.website.com/facebook/2011/voucher/fans_image.jpg" alt="10% off" style="border:0;" /></a>
        <div style="display:none; position:absolute; top:0; left:0;" id="voucher" >
        <a href="http://www.website.com/facebook/2011/voucher/voucher-11.pdf" target="_blank"><img src="http://www.website.com/facebook/2011/voucher/fb-voucher-dec11.jpg" style="border:0;" alt="10% off" /></a>  <br />
        <p style="text-align:center"><a href="http://www.website.com/facebook/2011/voucher/DECEMBER-11.pdf" target="_blank">Click here to download PDF version of the voucher.</a></p>
        </div>
        <?php
    }
    else
    {
        ?>
        <img style="position:absolute; top:0; left:0; border:0;" id="all" src="http://www.website.com/facebook/2011/voucher/fb_like_page.jpg" width="520" height="304" alt="Click LIKE button to get 10% off" />';
        <?php
    }
} catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
    }
}

if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} 
else {
    $loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'user_likes'
    ));
}

我过去开发过另一个 Facebook 应用程序,我也遇到过类似的问题,但它坏了几个小时,然后突然就可以工作了。

我一整天都在摆弄代码和应用程​​序设置,甚至将 iframe 中调用的 index.php 的权限更改为 755,但它仍然显示为空白:(

更多信息 该应用处于沙盒模式,以下是应用设置:

基本

Website: Site URL: http://www.website.com/

App on Facebook: Canvas URL: http://www.website.com/facebook/2011/discount-voucher/
               : Secure Canvas URL: https://www.website.com/facebook/2011/discount-voucher/

Page Tab: Page Tab URL: index.php
          Secure Page Tab URL: index.php

高级

 App Type: Web
 Deauthorize Callback: *blank*
 Sandbox Mode: Disabled

Migrations:
Remove Deprecated APIs: Enabled
Stream post URL security: Disabled
Timezone-less events: Enabled
Upgrade to Requests 2.0: Enabled
Require manage_notifications: Enabled
Include recent activity stories: Enabled
Enhanced Auth Dialog: Enabled
page_hours_format: Enabled
Graph Batch API Exception Format: Enabled

I am trying to create a custom tab for a facebook page and it works perfectly for me in firefox and internet explorer 8 in both the tab on the page and as a direct link but for others it just appears blank.

I am also an admin of the page and if I try logging in as someone else then it becomes blank for me too.

Here is my code:

require 'src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId' => 'xxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxx',
));

$user = $facebook->getUser();

if ($user) {
try {
    $likes = $facebook->api("/me/likes/PAGEID");
    if( !empty($likes['data']) )
    {
        ?>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('#fan').click(function() {
                $('#fan').animate({
                    opacity: 0.2,
                    width: 'auto',
                    height: 'auto'
                }, 1000, function() {
                    // Animation complete.
                    $('#fan').hide('slow');
                    $('#voucher').show('slow');
                });
            });
        });
        </script>

        <a href="#"><img id="fan" src="http://www.website.com/facebook/2011/voucher/fans_image.jpg" alt="10% off" style="border:0;" /></a>
        <div style="display:none; position:absolute; top:0; left:0;" id="voucher" >
        <a href="http://www.website.com/facebook/2011/voucher/voucher-11.pdf" target="_blank"><img src="http://www.website.com/facebook/2011/voucher/fb-voucher-dec11.jpg" style="border:0;" alt="10% off" /></a>  <br />
        <p style="text-align:center"><a href="http://www.website.com/facebook/2011/voucher/DECEMBER-11.pdf" target="_blank">Click here to download PDF version of the voucher.</a></p>
        </div>
        <?php
    }
    else
    {
        ?>
        <img style="position:absolute; top:0; left:0; border:0;" id="all" src="http://www.website.com/facebook/2011/voucher/fb_like_page.jpg" width="520" height="304" alt="Click LIKE button to get 10% off" />';
        <?php
    }
} catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
    }
}

if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} 
else {
    $loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'user_likes'
    ));
}

I have developed one other Facebook app in the past that I had similar problems with but that was broke for a few hours and then all of a sudden worked.

I have been fiddling with this all day with the code and the app settings and even changed the permissions of the index.php that is being called in the iframe to 755 but it's still appearing blank :(

More Info
The app is not in sandbox mode, here are the app settings:

Basic

Website: Site URL: http://www.website.com/

App on Facebook: Canvas URL: http://www.website.com/facebook/2011/discount-voucher/
               : Secure Canvas URL: https://www.website.com/facebook/2011/discount-voucher/

Page Tab: Page Tab URL: index.php
          Secure Page Tab URL: index.php

Advanced

 App Type: Web
 Deauthorize Callback: *blank*
 Sandbox Mode: Disabled

Migrations:
Remove Deprecated APIs: Enabled
Stream post URL security: Disabled
Timezone-less events: Enabled
Upgrade to Requests 2.0: Enabled
Require manage_notifications: Enabled
Include recent activity stories: Enabled
Enhanced Auth Dialog: Enabled
page_hours_format: Enabled
Graph Batch API Exception Format: Enabled

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

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

发布评论

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

评论(1

讽刺将军 2024-12-26 12:38:56

尝试更改您的页面选项卡 URL安全页面选项卡 URL 以反映实际的绝对 URL。

Try changing your Page Tab URL and Secure Page Tab URL to reflect actual, absolute URL's.

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