如何在facebook移动应用程序上向facebook好友发送应用程序邀请?
我有一个网站和一个facebook画布应用程序。网站上的用户可以创建内容,然后邀请他们的facebook好友观看。当他们这样做时,他们的朋友会在facebook(在facebook.com上)上收到通知,链接会将他们带到我的facebook画布页面。很好 现在,我想对使用facebook移动应用程序(而不是facebook.com)的朋友也这样做。因此,如果我网站上的用户邀请朋友,我希望该朋友能够在他们的facebook移动应用程序中看到通知,然后单击链接将他们带到我的网站上查看内容。我的网站没有移动应用程序,因此我希望链接通过web浏览器转到我的网站 这可能吗 如果没有,那么让你的网站允许用户邀请facebook好友,然后这些好友在facebook移动应用程序上得到通知的最佳方式是什么如何在facebook移动应用程序上向facebook好友发送应用程序邀请?,facebook,center,Facebook,Center,我有一个网站和一个facebook画布应用程序。网站上的用户可以创建内容,然后邀请他们的facebook好友观看。当他们这样做时,他们的朋友会在facebook(在facebook.com上)上收到通知,链接会将他们带到我的facebook画布页面。很好 现在,我想对使用facebook移动应用程序(而不是facebook.com)的朋友也这样做。因此,如果我网站上的用户邀请朋友,我希望该朋友能够在他们的facebook移动应用程序中看到通知,然后单击链接将他们带到我的网站上查看内容。我的网站没
这一点之所以重要,是因为我网站上的用户将创建对时间敏感的内容,所以我不想让他们不得不等待他们的朋友出现在facebook.com上的电脑前。我希望他们的朋友在世界上任何地方打开facebook移动应用程序时都能立即获得此信息。此代码可帮助您发布、发送消息,并向朋友发送请求: 头标签:
<script type="text/javascript">
function logResponse(response) {
if (console && console.log) {
console.log('The response was', response);
}
}
$(function(){
// Set up so we handle click on the buttons
$('#postToWall').click(function() {
FB.ui(
{
method : 'feed',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendToFriends').click(function() {
FB.ui(
{
method : 'send',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendRequest').click(function() {
FB.ui(
{
method : 'apprequests',
message : $(this).attr('data-message')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
});
</script>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxxxxxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Listen to the auth.login which will be called when the user logs in
// using the Login button
FB.Event.subscribe('auth.login', function(response) {
// We want to reload the page now so PHP can read the cookie that the
// Javascript SDK sat. But we don't want to use
// window.location.reload() because if this is in a canvas there was a
// post made to this page and a reload will trigger a message to the
// user asking if they want to send data again.
window.location = window.location;
});
FB.Canvas.setAutoGrow();
};
// Load the SDK Asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<header class="clearfix">
<?php if (isset($basic)) { ?>
<p id="picture" style="background-image: url(https://graph.facebook.com/<?php echo he($user_id); ?>/picture?type=normal)"></p>
<div>
<h1>Welcome, <strong><?php echo he(idx($basic, 'name')); ?></strong></h1>
<p class="tagline">
This is your app
<a href="<?php echo he(idx($app_info, 'link'));?>" target="_top"><?php echo he($app_name); ?></a>
</p>
<div id="share-app">
<p>Share your app:</p>
<ul>
<li>
<a href="#" class="facebook-button" id="postToWall" data-url="<?php echo AppInfo::getUrl(); ?>">
<span class="plus">Post to Wall</span>
</a>
</li>
<li>
<a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>">
<span class="speech-bubble">Send Message</span>
</a>
</li>
<li>
<a href="#" class="facebook-button apprequests" id="sendRequest" data-message="Test this awesome app">
<span class="apprequests">Send Requests</span>
</a>
</li>
</ul>
</div>
</div>
<?php } else { ?>
<div>
<h1>Welcome</h1>
<div class="fb-login-button" data-scope="user_likes,user_photos"></div>
</div>
<?php } ?>
</header>
功能日志响应(响应){
if(console&&console.log){
log('响应是',响应);
}
}
$(函数(){
//设置以便我们处理单击按钮
$('#postToWall')。单击(函数(){
FB.ui(
{
方法:“提要”,
链接:$(this.attr('data-url'))
},
功能(响应){
//如果响应为null,则用户取消了该对话框
if(响应!=null){
对数响应(响应);
}
}
);
});
$('#sendToFriends')。单击(函数(){
FB.ui(
{
方法:“发送”,
链接:$(this.attr('data-url'))
},
功能(响应){
//如果响应为null,则用户取消了该对话框
if(响应!=null){
对数响应(响应);
}
}
);
});
$('#sendRequest')。单击(函数(){
FB.ui(
{
方法:“apprequests”,
消息:$(this.attr('data-message'))
},
功能(响应){
//如果响应为null,则用户取消了该对话框
if(响应!=null){
对数响应(响应);
}
}
);
});
});
正文标签:
<script type="text/javascript">
function logResponse(response) {
if (console && console.log) {
console.log('The response was', response);
}
}
$(function(){
// Set up so we handle click on the buttons
$('#postToWall').click(function() {
FB.ui(
{
method : 'feed',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendToFriends').click(function() {
FB.ui(
{
method : 'send',
link : $(this).attr('data-url')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
$('#sendRequest').click(function() {
FB.ui(
{
method : 'apprequests',
message : $(this).attr('data-message')
},
function (response) {
// If response is null the user canceled the dialog
if (response != null) {
logResponse(response);
}
}
);
});
});
</script>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxxxxxx', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Listen to the auth.login which will be called when the user logs in
// using the Login button
FB.Event.subscribe('auth.login', function(response) {
// We want to reload the page now so PHP can read the cookie that the
// Javascript SDK sat. But we don't want to use
// window.location.reload() because if this is in a canvas there was a
// post made to this page and a reload will trigger a message to the
// user asking if they want to send data again.
window.location = window.location;
});
FB.Canvas.setAutoGrow();
};
// Load the SDK Asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<header class="clearfix">
<?php if (isset($basic)) { ?>
<p id="picture" style="background-image: url(https://graph.facebook.com/<?php echo he($user_id); ?>/picture?type=normal)"></p>
<div>
<h1>Welcome, <strong><?php echo he(idx($basic, 'name')); ?></strong></h1>
<p class="tagline">
This is your app
<a href="<?php echo he(idx($app_info, 'link'));?>" target="_top"><?php echo he($app_name); ?></a>
</p>
<div id="share-app">
<p>Share your app:</p>
<ul>
<li>
<a href="#" class="facebook-button" id="postToWall" data-url="<?php echo AppInfo::getUrl(); ?>">
<span class="plus">Post to Wall</span>
</a>
</li>
<li>
<a href="#" class="facebook-button speech-bubble" id="sendToFriends" data-url="<?php echo AppInfo::getUrl(); ?>">
<span class="speech-bubble">Send Message</span>
</a>
</li>
<li>
<a href="#" class="facebook-button apprequests" id="sendRequest" data-message="Test this awesome app">
<span class="apprequests">Send Requests</span>
</a>
</li>
</ul>
</div>
</div>
<?php } else { ?>
<div>
<h1>Welcome</h1>
<div class="fb-login-button" data-scope="user_likes,user_photos"></div>
</div>
<?php } ?>
</header>
window.fbAsyninit=函数(){
FB.init({
appId:'xxxxxxxxxxxxxxxx',//应用程序ID
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
//收听auth.login,用户登录时将调用它
//使用登录按钮
FB.Event.subscribe('auth.login',函数(响应){
//我们希望现在重新加载页面,以便PHP能够读取
//Javascript SDK。但是我们不想使用
//因为如果这是在画布中,则有一个
//对该页面进行post并重新加载将触发向
//询问是否要再次发送数据的用户。
window.location=window.location;
});
FB.Canvas.setAutoGrow();
};
//异步加载SDK
(功能(d、s、id){
var js,fjs=d.getElementsByTagName[0];
if(d.getElementById(id))返回;
js=d.createElement;js.id=id;
js.src=“//connect.facebook.net/en_US/all.js”;
fjs.parentNode.insertBefore(js,fjs);
}(文档“脚本”、“facebook jssdk”);
从Facebook:
有关更多详细信息,请参阅。这太棒了。我将使用提供的代码进行测试。你知道这类帖子是否会出现在用户在facebook移动应用程序上的facebook订阅源上吗?例如,如果我使用此代码向你发帖,而你在facebook移动应用程序上,你会看到帖子吗?