致命错误:在第 15 行 /home/wubb/public_html/facebook/fbml.php 中调用未定义的方法 Facebook::require_frame()

发布于 2024-12-07 01:55:05 字数 2655 浏览 0 评论 0原文

我正在尝试将 Facebook 的好友邀请集成到我的网站中。我正在使用 php。我包含了代码:


<?PHP
// Get these from http://developers.facebook.com
$api_key = 'xxx';
$secret  = 'xxx';
// Names and links
$app_name = "Application name";
$app_url = "app-url"; // Assumes application is at http://apps.facebook.com/app-url/
$invite_href = "invite.php"; // Rename this as needed
require_once 'facebook.php';
$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $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='.$user.') 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=\"".$user."\" 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
}
?>
[[Image:multi-friend-selector.png]]

这里我包含了从github下载的facebook.php文件。我尝试了许多版本的phpSDK,但仍然出现以下错误

致命错误:调用未定义的方法Facebook::require_frame()

任何人都可以建议哪个版本包含这个功能或者如何解决这个问题。我花了很多时间试图解决这个问题。所以尽快回复。

I am trying to integrate friend invite for facebook in my website. I am using php. I included the code:


<?PHP
// Get these from http://developers.facebook.com
$api_key = 'xxx';
$secret  = 'xxx';
// Names and links
$app_name = "Application name";
$app_url = "app-url"; // Assumes application is at http://apps.facebook.com/app-url/
$invite_href = "invite.php"; // Rename this as needed
require_once 'facebook.php';
$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $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='.$user.') 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=\"".$user."\" 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
}
?>
[[Image:multi-friend-selector.png]]

Here I included facebook.php file I downloaded from the github .I tried many versions of phpSDK but still the following error is coming

Fatal error: Call to undefined method Facebook::require_frame()

Can anybody suggest which version conatain this function or how to solve this issue. I have lost a lot of time trying to solve this. So respond as soon as possible.

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

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

发布评论

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

评论(1

吃兔兔 2024-12-14 01:55:05

Trikode,

确保您使用的是最新版本的 php sdk:https://github.com /facebook/facebook-php-sdk。这里有一个非常容易遵循的指南来帮助您入门:https://developers.facebook .com/docs/reference/php/

Trikode,

Make sure you are using the most recent version of the php sdk: https://github.com/facebook/facebook-php-sdk. There is a really easy to follow guide here to help you get started: https://developers.facebook.com/docs/reference/php/

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