Facebook fb:请求表单不起作用

发布于 2024-10-21 17:47:43 字数 2400 浏览 1 评论 0原文

我只是尝试使用 Developers.facebook.com 上给出的示例打开请求表单并邀请朋友,所以我相应地更改了所有内容,但没有任何反应,我需要以某种方式启动它吗?

<?php
$api_key = '...';
$secret  = '...';
require_once 'facebook.php';

// Names and links
$app_name = "...";
$app_url = "http://apps.facebook.com/.../"; // Assumes application is at http://apps.facebook.com/app-url/
$invite_href = "invite.php"; // Rename this as needed

$facebook->require_frame();
$user2 = $facebook->require_login();

if(isset($_POST["ids"])) {
    echo "<center>Thank you for inviting ".sizeof($_POST["ids"])." of your friends on <b><a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a></b>.<br><br>\n";
    echo "<h2><a href=\"http://apps.facebook.com/".$app_url."/\">Click here to return to ".$app_name."</a>.</h2></center>";
} else {
    // Retrieve array of friends who've already authorized the app.
    $fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$user2.') AND is_app_user = 1';
    $_friends = $facebook->api_client->fql_query($fql);

    // Extract the user ID's returned in the FQL request into a new array.
    $friends = array();
    if (is_array($_friends) && count($_friends)) {
        foreach ($_friends as $friend) {
            $friends[] = $friend['uid'];
        }
    }

    // Convert the array of friends into a comma-delimeted string.
    $friends = implode(',', $friends);

    // Prepare the invitation text that all invited users will receive.
    $content =
        "<fb:name uid=\"".$user2."\" firstnameonly=\"true\" shownetwork=\"false\"/> has started using <a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a> and thought it's so cool even you should try it out!\n".
        "<fb:req-choice url=\"".$facebook->get_add_url()."\" label=\"Put ".$app_name." on your profile\"/>";

?>
<fb:request-form
    action="<? echo $invite_href; ?>"
    method="post"
    type="<? echo $app_name; ?>"
    content="<? echo htmlentities($content,ENT_COMPAT,'UTF-8'); ?>">

    <fb:multi-friend-selector
        actiontext="Here are your friends who don't have <? echo $app_name; ?> yet. Invite whoever you want -it's free!"
        exclude_ids="<? echo $friends; ?>" />
</fb:request-form>
<?php

}

?>

I just tried using the example given on developers.facebook.com to open a request form and invite friends, so I changed everything accordingly but nothing happens, do I need to launch it in some way?

<?php
$api_key = '...';
$secret  = '...';
require_once 'facebook.php';

// Names and links
$app_name = "...";
$app_url = "http://apps.facebook.com/.../"; // Assumes application is at http://apps.facebook.com/app-url/
$invite_href = "invite.php"; // Rename this as needed

$facebook->require_frame();
$user2 = $facebook->require_login();

if(isset($_POST["ids"])) {
    echo "<center>Thank you for inviting ".sizeof($_POST["ids"])." of your friends on <b><a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a></b>.<br><br>\n";
    echo "<h2><a href=\"http://apps.facebook.com/".$app_url."/\">Click here to return to ".$app_name."</a>.</h2></center>";
} else {
    // Retrieve array of friends who've already authorized the app.
    $fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$user2.') AND is_app_user = 1';
    $_friends = $facebook->api_client->fql_query($fql);

    // Extract the user ID's returned in the FQL request into a new array.
    $friends = array();
    if (is_array($_friends) && count($_friends)) {
        foreach ($_friends as $friend) {
            $friends[] = $friend['uid'];
        }
    }

    // Convert the array of friends into a comma-delimeted string.
    $friends = implode(',', $friends);

    // Prepare the invitation text that all invited users will receive.
    $content =
        "<fb:name uid=\"".$user2."\" firstnameonly=\"true\" shownetwork=\"false\"/> has started using <a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a> and thought it's so cool even you should try it out!\n".
        "<fb:req-choice url=\"".$facebook->get_add_url()."\" label=\"Put ".$app_name." on your profile\"/>";

?>
<fb:request-form
    action="<? echo $invite_href; ?>"
    method="post"
    type="<? echo $app_name; ?>"
    content="<? echo htmlentities($content,ENT_COMPAT,'UTF-8'); ?>">

    <fb:multi-friend-selector
        actiontext="Here are your friends who don't have <? echo $app_name; ?> yet. Invite whoever you want -it's free!"
        exclude_ids="<? echo $friends; ?>" />
</fb:request-form>
<?php

}

?>

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

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

发布评论

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

评论(1

妥活 2024-10-28 17:47:43

你好,以下代码对我有用

<fb:serverFbml width="760px">
  <script type="text/fbml">
    <fb:fbml>
      <fb:request-form
            action='http://apps.facebook.com/yoursite/'
            method='POST'
            type='photo fun'
            content="Let's fun with facebook
        <fb:req-choice url='http://www.yoursite.com' label='Register'/>"
        <fb:multi-friend-selector actiontext="Select your friends."></fb:multi-friend-selector>
     </fb:request-form>
   </fb:fbml>
  </script>
</fb:serverFbml>

hello the following code works for me

<fb:serverFbml width="760px">
  <script type="text/fbml">
    <fb:fbml>
      <fb:request-form
            action='http://apps.facebook.com/yoursite/'
            method='POST'
            type='photo fun'
            content="Let's fun with facebook
        <fb:req-choice url='http://www.yoursite.com' label='Register'/>"
        <fb:multi-friend-selector actiontext="Select your friends."></fb:multi-friend-selector>
     </fb:request-form>
   </fb:fbml>
  </script>
</fb:serverFbml>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文