2011-10-24 88 views
1

我正在使用應用程序請求表來獲取邀請發件人uid,但我得到一個空數組作爲結果。FQL - 應用程序請求表

// Run fql query 
     $params = array(
     'method' => 'fql.query', 
     'query' => "SELECT request_id, app_id, recipient_uid, sender_uid FROM apprequest 
     WHERE app_id = 234234324324324 and request_id =".$request_id, 
    ); 

    $result = $facebook->api($params); 
+0

試過包括你的access_token? – OptimusCrime

+0

OptimusCrime:在哪裏添加access_tokn以及如何獲取該訪問令牌 – user1010611

+0

如果您使用PHP SDK和$ facebook-> api(),則不需要處理access_token;方法 – Luke

回答

-1
// Run fql query 
$params = array(
    'method' => 'fql.query', 
    'query' => "SELECT request_id, app_id, recipient_uid, sender_uid FROM apprequest WHERE app_id = 234234324324324 and request_id =".$request_id, 
    'access_token' => $yourAccessTokenVar); 

我假設你有一個variabel(你需要這個來獲取應用程序運行)您的access_token代碼,只需用這個變量替換$yourAccessTokenVar

編輯:順便說一句,你的數組中有太多的逗號。

+0

但它在我的code.I'm沒有找到它 – user1010611

+0

因爲用戶使用Facebook PHP SDK,這是自動處理我相信 – Luke

+0

很難告訴沒有看到您的代碼。介紹使用新Facebook的代碼部分();在你的腳本?發佈在http://pastebin.com/或別的東西(不要忘記檢查你的私人信息) – OptimusCrime

0

我想我有你的問題的答案。在文檔here,在列的表,它規定如下:

app_id: The ID of the app used to send the request. Note when indexing by app_id, you must also specify the recipient_uid.

- 和 -

recipient_uid: The ID of the user who received the request. Note when indexing by recipient_uid, you must also specify the app_id.

當我試圖執行查詢,我收到以下錯誤:

"message": "(#604) Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql ", 

您查詢是目前:

SELECT request_id, app_id, recipient_uid, sender_uid FROM apprequest WHERE app_id = 234234324324324 and request_id =".$request_id

你會發現,你不遵循這些規則,你指定在WHERE子句,但沒有「recipient_uid」 APP_ID「。

嘗試在未指定app_id的情況下執行查詢。

+0

:我想邀請發件人uid – user1010611

+0

說我是a,發送請求到b.i需要一個uid.where是那個access_token在Facebook – user1010611

+0

@ user1010611道歉,我得到了棒的錯誤結束。請參閱我的修訂答案 – Luke

0

這是爲我工作:

void FacebookManager::GetRequests() 
{ 
    FBRequest *fql = [FBRequest requestForGraphPath:@"fql"]; 
    [fql.parameters setObject:@"SELECT request_id, app_id, recipient_uid FROM apprequest WHERE app_id = <your app id> AND recipient_uid = <your fbid>" 
         forKey:@"q"]; 

    FBRequestConnection* rc = [fql startWithCompletionHandler:^(FBRequestConnection *connection, 
             id result, 
             NSError *error) { 
     if (result) { 
      NSLog(@"result:%@", result); 
     } 
    }]; 
} 

這使我寫入調試輸出窗口JSON數組。