Ruby Koala fql_multiquery parser error

538 Views Asked by At

Sending 10 queries to Facebook's REST API. Calling the REST API through Koala's fql_multiquery function with the following as the input hash:

{"query11"=>"SELECT page_id, name, fan_count, page_url FROM page WHERE name='Wyoming Area Sec Center' ORDER BY fan_count DESC LIMIT 1", "query12"=>"SELECT page_id, name, fan_count, page_url FROM page WHERE name='Wyoming Area High School Exeter PA' ORDER BY fan_count DESC LIMIT 1", ...}

Queries all seem well-formed but Koala returns with:

Koala::Facebook::APIError: 601: Parser error: unexpected 's' at position 73.

Anybody run into this error code before?

1

There are 1 best solutions below

1
On

oops! this is the problem:

{"query18"=>"SELECT page_id, name, fan_count, page_url FROM page WHERE name='Governor's Academy' ORDER BY fan_count DESC LIMIT 1"}

The apostrophe in Governor's Academy is unescaped. This can be solved by simply escaping the FQL query inputs with something like

str.gsub(/\\|'/) { |c| "\\#{c}" }