gpt4 book ai didi

Facebook Canvas 应用程序 - 邀请 friend

转载 作者:行者123 更新时间:2023-11-30 05:24:47 31 4
gpt4 key购买 nike

我正在编写一个 Facebook iframe/canvas 应用程序,并希望让用户能够邀请 friend 安装此应用程序。目前我正在使用 Facebook 的 PHP-SDK 来登录用户以及与 Facebook 的所有交互。我能找到的关于实现邀请好友对话框的唯一内容要么与 FBML 相关,后者已被弃用;或请求对话框:https://developers.facebook.com/docs/reference/dialogs/requests/ .后者似乎需要使用 Facebook 的 Javascript SDK,它有自己的登录方法。

JS SDK 是我唯一的选择吗?如果是,我如何使用它而不强制我的用户必须重新登录?

最佳答案

第一种方法:

function newInvite(){
var receiverUserIds = FB.ui({
method : 'apprequests',
message: 'Come on man checkout my applications.',
},
function(receiverUserIds) {
console.log("IDS : " + receiverUserIds.request_ids);
}
);
//http://developers.facebook.com/docs/reference/dialogs/requests/
}

第二种方法:

<?php
include_once "fbmain.php";
if (isset($_REQUEST['ids'])){
echo "Invitation Successfully Sent";
echo '<pre>';
print_r($_REQUEST);
echo '</pre>';
echo "<b>If you need to save these user ids then save these to database <br />then redirect user to the apps.facebook.com/yourapp url</b>";
$string = "<script type='text/javascript'>top.location.href='{$fbconfig['appBaseUrl']}'; </script>";
echo "Use the following javascript code to redirect user <br />";
echo htmlentities($string, ENT_QUOTES);
}
else {
?>
<fb:serverFbml style="width: 500px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="<?=$fbconfig['baseUrl']?>/invite.php"
target="_top"
method="POST"
invite="true"
type="Demo Application Learning API"
content="Checkout this demo application and learn iframe base facebook application development. <fb:req-choice url='<?=$fbconfig['appBaseUrl']?>' label='Accept' />"
>

<fb:multi-friend-selector
showborder="false"
actiontext="Checkout this demo application">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
<?php } ?>

第三种方法(使用 PHP-SDK):

     $app_id = "YOUR_APP_ID";

$canvas_page = "YOUR_CANVAS_PAGE_URL";

$message = "Would you like to join me in this great app?";

$requests_url = "http://www.facebook.com/dialog/apprequests?app_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page)
. "&message=" . $message;

if (empty($_REQUEST["request_ids"])) {
echo("<script> top.location.href='" . $requests_url . "'</script>");
} else {
echo "Request Ids: ";
print_r($_REQUEST["request_ids"]);
}
?>

关于Facebook Canvas 应用程序 - 邀请 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6580702/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com