Can I send a request to friend from app without users promting to do so?
我需要特殊的permission?
如果我不能在没有要求的情况下从app发送请求 - 我可以要求用户向朋友发送请求而不让他选择哪一个吗? (应用程序将指定他可以发送的内容,将其用于游戏)。
答案 0 :(得分:1)
是的,你可以在没有任何扩展权限的情况下这样做。查看Facebook对话框documentation for requests,它解释并显示请求渠道如何与图谱API对话框一起使用。
此示例还显示了通过Facebook JS SDK使用应用请求的各种方式。
<h1>requests</h1>
<button id="send-to-many">Send to Many</button>
<button id="custom-filters">Custom Filters</button>
<button id="send-to-one">Send to One</button>
<button id="send-app-to-user">Send App-to-User</button>
<button id="list-pending">List Pending</button>
<button id="clear-pending">Clear Pending</button>
<button id="clear-prompted">Clear Prompted</button>
<script>
document.getElementById('send-to-many').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'You should learn more about the @[19292868552:Platform].'
}, Log.info.bind('send-to-many callback'));
}
document.getElementById('custom-filters').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'Have you heard about @[184484190795:Rell]?',
data: 'invite-to-rell-42',
filters: [{name: 'Daaku', user_ids: ['1677846385']}, 'app_non_users', {name: 'Games People', user_ids: [703, 6203644]}]
}, Log.info.bind('send-to-many callback'));
}
document.getElementById('send-to-one').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'A request especially for @[1677846385:Daaku].',
to: '1677846385',
data: 'send-to-one-42'
}, Log.info.bind('send-to-one callback'));
}
document.getElementById('send-app-to-user').onclick = function() {
FB.api(
'/me/apprequests',
{ message: 'From the app to the user.' },
'POST',
Log.info.bind('sent app-to-user request'));
}
document.getElementById('list-pending').onclick = function() {
FB.api('/me/apprequests', Log.info.bind('pending requests'));
}
document.getElementById('clear-pending').onclick = function() {
FB.api('/me/apprequests', function(response) {
var ids = [];
for (var i=0, l=response.data.length; i<l; i++) {
FB.api('/' + response.data[i].id, 'DELETE', Log.info.bind('clear requests'));
}
});
}
document.getElementById('clear-prompted').onclick = function() {
FB.api(
prompt('Enter the ID of the request to delete:'),
'DELETE',
Log.info.bind('delete request'));
}
</script>