在我的页面上,人们可以按下共享按钮并在Facebook上发布。我使用以下代码:
window.fbAsyncInit = function() {
FB.init(
{
"appId" : "<?php echo $fbid; ?>",
"status" : true,
"cookie" : true,
"xfbml" : true,
"oauth" : true
});
单击函数showStreamPublish启动:
function showStreamPublish() {
FB.ui(
{
method: 'feed',
name: 'Text',
caption: 'Text',
link: 'Link',
picture:'Pic',
description: 'ni',
user_message_prompt: 'Share it!'
},
function(response) {
if (response && response.post_id) {
FB.api('/me', function(response)
{alert(response.name);
}); ...
在使用以下代码时,我想显示做Sahre的人的用户名,但它没有:(
FB.api('/me', function(response)
{alert(response.name);
});
我如何才能得到用户名或UserID的人谁做的分享?它打开警报框-以“未定义”作为内容。谢谢你的帮助。
我试图获得response.status,奇怪的是:即使我通过我的应用程序连接并在Facebook上发布,我也会从我的应用程序中得到这样的信息:我不是连接体。使用该守则:
if (response.status === 'connected') {
// the user is logged in and has authenticated your app
alert('All good');
}else if (response.status === 'not_authorized') {
// the user is logged in but NOT through your app
alert('Not good');
}else{
alert('What the heck?');// the user isn't logged in to Facebook.
}
});
尼尔
发布于 2013-03-18 02:26:42
我看到两件我感觉不好的事情:
FB.api
调用包含在FB.ui
中。response
两次:FB.ui({...}, function(response) {...
,FB.api('/me', function(response) {...
。
这两个问题可能是相关的或不相关的。但这会使它:
function showUserName() {
FB.api('/me', function(response) {
alert('Post was published by ' + response.name);
});
}
function showStreamPublish() {
FB.ui({
method: 'feed',
name: 'Text',
caption: 'Text',
link: 'Link',
picture: 'Pic',
description: 'ni',
user_message_prompt: 'Share it!'
}, function(response) {
if (response && response.post_id) {
showUserName();
} else {
alert('Post was not published.');
}
}
);
https://stackoverflow.com/questions/15473818
复制