0

我仍然不太确定多查询语法..

我想获得一些照片数据,我想将它与地点连接起来,这样我就可以获得照片的地点信息..

这是我的代码

query1 = "SELECT+object_id+,+place_id+,+caption+,+images+,+owner+,+created+FROM+photo+" \
         "WHERE+owner=%s+AND+created>=%s" % (update_user, update_ti
query2 = "SELECT+name+,+latitude+,+longitude+FROM+place+" \
         "WHERE+page_id+IN+(+SELECT+place_id+FROM+#query1+)"
update_url = "https://graph.facebook.com/fql?q={'query1':'%s', 'query2':'%s'}" \
             "&access_token=%s" % (query1, query2, client.token)

在http请求中会是这样的

https://graph.facebook.com/fql?q={"query1":"SELECT+object_id,+place_id,+caption,+images,+owner,+created+FROM+photo+WHERE+owner=[user_id]+AND+created>=1383158944","query2":"SELECT+name,+latitude,+longitude+FROM+place+WHERE+page_id+IN+(SELECT+place_id+FROM+#query1+)"}&access_token=my_token

它返回给我 OAuthException:

error: {
  message: "(#601) Parser error: unexpected '{' at position 0.",
  type: "OAuthException",
  code: 601
}

更新的代码(工作):

query1 = "SELECT object_id, place_id, caption, images, owner, created FROM photo " \
         "WHERE owner=%s AND created>=%s" % (update_user, update_time)
query2 = "SELECT name, latitude, longitude FROM place " \
         "WHERE page_id IN (SELECT place_id FROM #query1)"
query_params = {
    'q': '{"query1":"%s", "query2":"%s"}' % (query1, query2),
    'access_token': client.token
}
update_url = "https://graph.facebook.com/fql?%s" % urllib.urlencode(query_params)
4

1 回答 1

0

查询需要进行 URL 编码。

来自 python 的 FQL 多查询因 unicode 查询而失败

于 2013-10-30T19:42:01.133 回答