Question

I'm still not very sure about the multi-query syntax..

I want to get some photo data and I want to join it with place so I can get photo's place info..

Here's my code

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)

In http request it will be like this

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

It returns me OAuthException:

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

Updated code (working):

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)
Was it helpful?

Solution

The query needs to be URL encoded.

FQL multiquery from python fails with unicode query

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top