我发送邀请,下面的代码用于为您提供请求ID。我是发件人A.我发送邀请给b。我可以获得request_id但是如何获得A UID。
//get the request ids from the query parameter
$request_ids = explode(',', $_REQUEST['request_ids']);
//build the full_request_id from request_id and user_id
function build_full_request_id($request_id, $user_id) {
return $request_id . '_' . $user_id;
}
//for each request_id, build the full_request_id and delete request
foreach ($request_ids as $request_id)
{
echo ("reqeust_id=".$request_id."<br>");
$full_request_id = build_full_request_id($request_id, $user_id);
echo ("full_request_id=".$full_request_id."<br>");
try {
$delete_success = $facebook->api("/$full_request_id",'DELETE');
if ($delete_success) {
echo "Successfully deleted " . $full_request_id;}
else {
echo "Delete failed".$full_request_id;}
}
catch (FacebookApiException $e) {
echo "error";}
}
答案 0 :(得分:1)
已经很晚了,但我感谢这是你的回答...... How to send a Facebook application request to retrieve data on accepting?
if(isset($_GET['request_ids']))
{
$request_ids = $_GET['request_ids'];
$request_ids = explode(",", $request_ids);
for( $i=0; $i < count($request_ids); $i++ )
{
$request_object = $facebook->api($request_ids[$i]);
if(isset($request_object['data'])){
$req_data = $request_object['data'];
$i = 50 + count($request_ids);
}
}
}
FB.ui({method: 'apprequests',
redirect_uri: 'url',
message: ' your message',
data : '<?=$user_id?>'
}, requestCallback);
$req_data
将成为发件人用户ID。
答案 1 :(得分:0)
设置:$user_id_A = $facebook->getUser();
以下是有关getUser()方法的一些信息:https://developers.facebook.com/docs/reference/php/facebook-getUser/