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

时间:2011-09-28 05:25:01

标签: facebook-php-sdk fbml php invite

我正在尝试将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()

有人可以建议哪个版本包含此功能或如何解决此问题。我已经失去了很多时间来解决这个问题。所以尽快回复。

1 个答案:

答案 0 :(得分:1)

Trikode,

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