FQL - 应用程序请求表

时间:2011-10-24 10:02:11

标签: php facebook

我正在使用app请求表来获取邀请发件人uid,但结果是我得到一个空数组。

  // 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);

3 个答案:

答案 0 :(得分: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.

- AND -

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子句中指定了“app_id”但没有“recipient_uid”。

尝试在未指定app_id的情况下执行查询。

答案 1 :(得分: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数组。

答案 2 :(得分:-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);

我假设你在变量中有你的access_token代码(你需要这个才能让应用程序运行),只需用这个变量替换$yourAccessTokenVar

编辑:顺便说一句,你的数组中有一个逗号太多了。