我有apprequests和['app_non_users']过滤器的问题。代码:
window.fbAsyncInit = function() {
FB.init({appId: '123', status: true, cookie: true, xfbml: true});
}
function sendRequestViaMultiFriendSelector() {
FB.ui({
method: 'apprequests',
filters: ['app_non_users'],
message: 'Hello there!'
}, function callback(response) {
if (response) {
//do some stuff
}
});
}
正如你可能猜到facebook会显示所有朋友(甚至那些已经在使用该应用程序的朋友)。有什么建议吗?
谢谢!
答案 0 :(得分:0)
使用
function(response) {
// callback function
}
不是
function callback(response) {
// callback function
}
或者像这样......
FB.ui({method: 'apprequests',
title: app_title,
message:inviteMsg,
data:"invite" ,
filters: ['app_non_users']
}, inviteSent);
function inviteSent(response){
log(response);
}
答案 1 :(得分:0)
我发现这对我有用:
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'Check out this application!',
title: 'Send your friends an application request',
filters: ['app_non_users']
},
function (response) {
console.log(response);
if (response.request && response.to) {
var request_ids = [];
for(i=0; i<response.to.length; i++) {
var temp = response.request + '_' + response.to[i];
request_ids.push(temp);
}
var requests = request_ids.join(',');
$.post('<?=base_url()?>handle_requests',{uid: '<?php echo $user; ?>', request_ids: requests},function(resp) {
// callback after storing the requests
});
} else {
alert('canceled');
}
});
return false;
}