[英]Facebook Invite Friends Box with iframes is not loading
我創建了一個Facebook應用程序名稱bitutopia,我想使用php邀請我的朋友加入該應用程序。 我在該應用程序中使用iframe。 我從http://developers.facebook.com/docs/reference/fbml/request-form/ php腳本中獲得了此代碼,以顯示邀請好友框。 但它不起作用。 代碼-
<?php
// Get these from http://developers.facebook.com
$api_key = 'xxxx';
$secret = 'xxxx';
// Names and links
$app_name = "Bitsutopia";
$app_url = "https://apps.facebook.com/bitsutopia/";
$invite_href = "fb.php";
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:serverfbml style="width: 650px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="<?php echo $invite_href; ?>"
method="post"
type="<?php echo $app_name; ?>"
content="<?php echo htmlentities($content,ENT_COMPAT,'UTF-8'); ?>">
<fb:multi-friend-selector
actiontext="Here are your friends who don't have <?php echo $app_name; ?> yet. Invite whoever you want -it's free!"
exclude_ids="<?php echo $friends; ?>" />
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>
<?php
}
?>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(
["CanvasUtil"],
function(){
FB.XdComm.Server.init('/xd_receiver.html');
FB.CanvasClient.startTimerToSizeToContent();
}
);
</script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function(){ FB.Facebook.init("Your Facebook API Key", "/xd_receiver.html"); });
</script>
邀請框未出現在應用程序頁面中。 這個有什么問題嗎?
根據我的經驗,fmbl不適用於iframe應用
我們正在淘汰FBML。 如果要在Facebook.com上構建新應用程序,請使用HTML,JavaScript和CSS來實現您的應用程序。 您可以使用我們的JavaScript SDK和社交插件來嵌入FBML中可用的許多相同社交功能。 盡管仍有一些功能尚未移植,但我們不再向FBML添加新功能。 如http://developers.facebook.com/docs/reference/fbml/
我用
$requests_url = "http://www.facebook.com/dialog/apprequests?app_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page)
. "&message=" . $message;
echo("<script> top.location.href='" . $requests_url . "'</script>");
或與Java SDK
<script src="http://connect.facebook.net/tr_TR/all.js" type="text/javascript"></script>
<a href="#" onClick="FB.ui({method: 'apprequests', message: 'Here is your invite msg.', data: '', filters: ['all'], exclude_ids: ['ids,you,want,to,exclude']},
function(response) {if(response != null) {window.location='?requests='+response.request_ids;}});">Send Requests</a>
我更喜歡這一個:)但更難理解
<script src="http://connect.facebook.net/tr_TR/all.js" type="text/javascript"></script>
<a href="#" onClick="FB.ui({method: 'apprequests', message: 'Here is your invite msg.', data: '', filters: ['all'], exclude_ids: ['ids,you,want,to,exclude']}});">Send Requests</a>
如果您不擔心邀請的人,則無需重定向
對糟糕的復制和粘貼編碼感到抱歉。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.