2012-10-31 71 views

回答

1

我假設你會使用數據庫。當用戶邀請朋友時,發送的請求的響應將包含response.request和response.to。將此request_id與用戶和用戶朋友ID(受邀朋友)一起存儲。

function inviteuser(){ 
    FB.ui({ 
     method: 'apprequests', 
     message: "Apllications message goes here", 
     exclude_ids: [1, 2, 3], 
     filters:['app_non_users'], 
     data: "optional additional data you may pass for tracking" 
    }, function (response) { 
     if (response && response.to) { 
     //callback function, will be called after user invites his friend, response object will contain list of all users invited 
     //save response.to and response.request in database 
     } 
    }); 
} 

當用戶接受邀請,即通過點擊應用程序請求通知涉及到你的應用畫布頁,臉譜發送逗號「request_ids」參數分離的ID。您可以獲取此請求ID並與您的數據庫進行比較以獲取所需的信息。

2

在發送邀請,您可以添加任何數據跟蹤,讓說你想送sender_name讓你發送請求的功能將是這樣的:

FB.ui({ 
     method: 'apprequests', 
     message: "has invited you to the app", 
     filters:['app_non_users'], 
     data: sender_name 
    }, function (response) { 
    }); 

當接收器涉及到你的應用程序點擊請求通知發送,那麼你可以檢索數據並在php中刪除請求如下:

if(isset($_GET['request_ids'])) 
    { 
     $request_ids = $_GET['request_ids']; 
     $request_ids = explode(",", $request_ids); 
     foreach($request_ids as $request_id) 
      { 
       $request_object = $facebook->api($request_id); 
       if(isset($request_object['data'])) $req_data = $request_object['data'];//you can now use the sent $req_data your way 
       $full_request_id = $request_id."_".$current_user_fbid; 
       $facebook->api("$full_request_id","DELETE"); 
      } 
    } 
相關問題