Facebook Multiquery错误

时间:2011-12-22 08:20:09

标签: facebook

我遇到了facebook multiquery语法的问题

当我使用单个查询时,例如.simply复制并将其粘贴到您的浏览器中,您将获得结果

https://api.facebook.com/method/fql.query?query=SELECT metric, value FROM insights WHERE object_id=243995185663734 AND metric='application_active_users' AND end_time=end_time_date('2011-11-30') AND period=period('month')&access_token=243995185663734%7C3fAfdJJqdrgA99XWdE5K6zzeNR8

它给了我确切的真实结果。但现在我想使用multiquery,因为我必须获取多个指标的数据,但它给了我错误。

我使用此查询

 https://api.facebook.com/method/fql.multiquery? queries  ="{"query1": "SELECT metric, value FROM insights WHERE object_id=208344135910932 AND metric='application_active_users' AND end_time=end_time_date('2011-11-30') AND period=period('month')","query2": "SELECT metric, value FROM insights WHERE object_id=208344135910932 AND metric='application_active_users' AND end_time=end_time_date('2011-11-30') AND period=period('month')"}"&access_token=243995185663734|3fAfdJJqdrgA99XWdE5K6zzeNR8

请告诉我我是否使用了一些错误的语法来进行多重查询。这是我在xml中得到的错误响应。

 <error_response xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
    <error_code>100</error_code>
    <error_msg>The parameter queries is required</error_msg>
    <request_args list="true"><arg>
    <key>method</key>
    <value>fql.multiquery</value>
    </arg><arg>
    <key>queries__</key>
    <value>"{"query1": "SELECT metric, value FROM insights WHERE object_id=208344135910932 AND metric='application_active_users' AND end_time=end_time_date('2011-11-30') AND period=period('month')","query2": "SELECT metric, value FROM insights WHERE object_id=208344135910932 AND metric='application_active_users' AND end_time=end_time_date('2011-11-30') AND period=period('month')"}"
    </value>
    </arg><arg>
    <key>access_token</key>
    <value>243995185663734|3fAfdJJqdrgA99XWdE5K6zzeNR8</value></arg></request_args></error_response>

1 个答案:

答案 0 :(得分:0)

看起来你的JSON周围有一些空格和额外的引用,试试

https://api.facebook.com/method/fql.multiquery?queries={%22query1%22:%20%22SELECT%20metric,%20value%20FROM%20insights%20WHERE%20object_id=208344135910932%20AND%20metric='application_active_users'%20AND%20end_time=end_time_date('2011-11-30')%20AND%20period=period('month')%22,%22query2%22:%20%22SELECT%20metric,%20value%20FROM%20insights%20WHERE%20object_id=208344135910932%20AND%20metric='application_active_users'%20AND%20end_time=end_time_date('2011-11-30')%20AND%20period=period('month')%22}&access_token=243995185663734|3fAfdJJqdrgA99XWdE5K6zzeNR8

通过这个电话,我回来了:

<?xml version="1.0" encoding="UTF-8"?>
<fql_multiquery_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
  <fql_result>
    <name>query1</name>
    <fql_result_set list="true">
      <insights>
        <metric>application_active_users</metric>
        <value>0</value>
      </insights>
    </fql_result_set>
  </fql_result>
  <fql_result>
    <name>query2</name>
    <fql_result_set list="true">
      <insights>
        <metric>application_active_users</metric>
        <value>0</value>
      </insights>
    </fql_result_set>
  </fql_result>
</fql_multiquery_response>