我无法让用户将应用请求转发给他的朋友;
我在客户端使用下一个代码:
window.fbAsyncInit = function() {
FB.init({
appId: 'FBAPPD',
frictionlessRequests: true,
status : true,
cookie : true,
xfbml : true
});
};
当用户选择她的朋友时:
function sendRequestToRecipients() {
var user_ids = document.getElementById("request_ids").value; //ID_user1,ID_user2...
FB.ui({
method: 'apprequests',
message: 'Prueba una nueva forma de comunicarte con tus contactos...',
to: '' + user_ids + '',
}, requestCallback);
function requestCallback(response) {
// Handle callback here
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('/FB_Invitaciones', { uid: document.getElementById("FBUser").value, request_ids: requests }, function (resp) {
// callback after storing the requests
});
} else
{
alert('canceled');
}
}
服务器端
<?php
[...]
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $FBAPPID .
"&client_secret=" . $FBSECRETFBAPPID .
"&grant_type=client_credentials";
$app_access_token = file_get_contents($token_url);
$user_id = $datos->getFBID();
//Procesando ids
$ids = explode(",",$_REQUEST['request_ids']);
foreach($ids as $request)
{
$apprequest_url ="https://graph.facebook.com/" .$request.
"?".$app_access_token;
$result = file_get_contents($apprequest_url);
}
die()
?>
我找不到错误。
谢谢您的帮助