没有 FBML 使用 PHP 在 facebook 的 iframe 中工作(即或 ff 或其他任何地方!)

发布于 2024-08-26 11:39:05 字数 2361 浏览 6 评论 0原文

我已经尝试了三天,但一无所获......我绝对无法获得任何“fb:”代码来渲染任何内容!我已经在沙箱中尝试了确切的代码,它工作得很好。我已经阅读了我能找到的所有搜索结果,但一无所获...

我使用的是标准 xd_receiver 页面,在 body 中有这样一行:

< script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script> 

这是我的索引页面。它基本上是股票 facebook 示例代码......

<?php
require_once 'facebook-platform/php/facebook.php';

//Authentication Keys
$appapikey = 'MY_KEY';         // obviously this is my real key
$appsecret = 'MY_SECRET';      // same thing

$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();
?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
 <head></head>
 <body>
  <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

<?
   echo "<p>Hello, <fb:name uid=\"$user_id\" useyou=\"false\"></fb:name>!</p>";

?>

  <script type="text/javascript">
  FB_RequireFeatures(["XFBML"], function(){
   FB.Facebook.init("<?php echo $appapikey; ?>", "xd_receiver.htm");
  });
  </script>
 </body>
</html>

奇怪的是,当我将此代码放在与登录用户名相呼应的位置时,它确实显示了朋友的 ID 号。但同样,它不会呈现他们的名字

<?php
   friends.get API method echo "<p>Friends:";
   $friends = $facebook->api_client->friends_get();
   $friends = array_slice($friends, 0, 25);
   foreach ($friends as $friend) {
      echo "<br>".$friend." - <fb:name uid=\".$user_id.\" useyou=\"false\"></fb:name>";
   }
   echo "</p>";
?>

这是我的设置:

Canvas Callback URL http://www.my-actual-website.com/test/

画布网址 http://apps.facebook.com/gogre_testapp/

FBML/iframe iframe

应用程序类型 网站

删除 URL 后的 http://www.my-actual-website.com/test/

帖子- 授权网址 http://www.my-actual-website.com/test/

请,有人帮帮我!我已经尝试了几天但没有成功

I have tried for three days now and gotten nowhere on this.... I absolutely can not get any "fb:" code to render anything! I've tried the exact code in the sandbox and it works fine. I've read through every search result I could find and gotten nowhere...

I'm using a standard xd_receiver page, and in the body there's this line:

< script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script> 

Here's my index page. It's basically the stock facebook example code....

<?php
require_once 'facebook-platform/php/facebook.php';

//Authentication Keys
$appapikey = 'MY_KEY';         // obviously this is my real key
$appsecret = 'MY_SECRET';      // same thing

$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();
?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
 <head></head>
 <body>
  <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

<?
   echo "<p>Hello, <fb:name uid=\"$user_id\" useyou=\"false\"></fb:name>!</p>";

?>

  <script type="text/javascript">
  FB_RequireFeatures(["XFBML"], function(){
   FB.Facebook.init("<?php echo $appapikey; ?>", "xd_receiver.htm");
  });
  </script>
 </body>
</html>

oddly enough, when I put this code below where it echos the logged in user's name, it does show the id numbers of friends. But again, it won't render their names

<?php
   friends.get API method echo "<p>Friends:";
   $friends = $facebook->api_client->friends_get();
   $friends = array_slice($friends, 0, 25);
   foreach ($friends as $friend) {
      echo "<br>".$friend." - <fb:name uid=\".$user_id.\" useyou=\"false\"></fb:name>";
   }
   echo "</p>";
?>

Here's my settings:

Canvas Callback URL
http://www.my-actual-website.com/test/

Canvas URL
http://apps.facebook.com/gogre_testapp/

FBML/iframe
iframe

Application Type
Website

Post-Remove URL
http://www.my-actual-website.com/test/

Post-Authorize URL
http://www.my-actual-website.com/test/

Please, somebody help me out! I've been trying unsuccessfully for days

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

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

发布评论

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

评论(1

糖粟与秋泊 2024-09-02 11:39:05

XFBML 问题通常是由于 Facebook 无法访问您的 xd_receiver.htm 文件造成的。尝试将完整的 URL 放入 xd_receiver.htm,即。在 FB.Facebook.init 行中的 http://yourdomain.com/xd_receiver.htm ,并通过手动访问来确保该文件正常运行。

肯定会导致此问题的另一件事是无法在应用设置中设置连接 URL。转到开发者应用程序并编辑您的设置。在“连接”选项下,将“连接 URL”设置为您的主站点,即。 http://yourdomain.com/

XFBML problems are often a result of Facebook being unable to access your xd_receiver.htm file. Try putting the full URL to xd_receiver.htm, ie. http://yourdomain.com/xd_receiver.htm in the FB.Facebook.init line, and make sure that the file is being served properly by accessing it manually.

The other thing that will definitely cause this is failing to set the Connect URL in your app settings. Go to the Developer app and edit your settings. Under the Connect options, set the Connect URL to your main site, ie. http://yourdomain.com/.

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