有没有人经历过FB.ui的" to“属性被忽略的情况--即使设置了它--而post只会到达当前登录用户的墙壁?
当使用一个使用FB示例代码(和硬编码参数值)的完全简化的测试页面时,它会像预期的那样发布到我的墙壁上。但是当我在这个FB代码中添加" to“属性时,它仍然只会张贴到我的墙上。
任何想法都会非常感谢,因为我已经拖网这些档案和FB开发网站,我认为是一个彻底的方式。
SDK正确加载并弹出iframe (尽管它会滚动到页面的顶部)。
下面是在我的测试页面中使用的简化代码:
$("#well").click(function(e) {
FB.ui(
{
method: 'feed',
to: '***', /* <=== this person is a confirmed friend with appropriate privacy settings */
name: 'The Facebook SDK for Javascript',
caption: 'Bringing Facebook to the desktop and mobile web',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
link: 'https://developers.facebook.com/docs/reference/javascript/',
picture: 'http://www.fbrell.com/public/f8.jpg'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);提前谢谢。
##更新
多亏了萨希尔·米塔尔的贡献,我找到了一个相当合理的解决方案:
`
var jqxhr = $.get( "http://graph.facebook.com/"+$("#fbto").val()+"?fields=id", function( data ) {
// could do something useful here...
})
.done(function( data ) {
// do something else useful useful, in this case finish posting stuff to the wall
})
.fail(function( data ) {
// thrown if the user doesn't exist
})
.always(function( data ) {
// etc...
})`
现在,这是一个jQuery 1.8.*解决方案,我还应该补充一点,在一个高流量的场景中,我不确定FB会有多好地敲击他们的URL来将提交的用户名转换为ids。但那是一座桥,如果我们到了那里,我会很高兴穿过的!
再次感谢萨希尔。
发布于 2014-04-25 08:10:20
不能在username参数中使用to。您必须使用id代替。
如果您没有id,您可以从用户名本身获得这个信息。打电话给/{username}?fields=id,您就会得到id作为响应。
例如:http://graph.facebook.com/sahilmittal?fields=id。
答复是:
{
id: "595273610"
}只需获取这个id并在id参数中使用它。
https://stackoverflow.com/questions/23286157
复制相似问题