arsduo / koala

A lightweight Facebook library supporting the Graph, Marketing, and Atlas APIs, realtime updates, test users, and OAuth.

Home Page:http://developers.facebook.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when calling batch_api.get_object(id:number, {fields: 'email, ...'})

tscholz opened this issue · comments

Hi there

Thank you for the great gem!

Because of Facebook API 2.3 end of life we are forced to explicitly request extra info_fields like email, first_name etc. now. Our application depends on these extra fields.

By doing so we're running into an issue with the GraphBatchApi#graph_call method.

facebook = Koala::Facebook::API.new(oauth_token)

ids = [123456456, ...] # Some Facebook user ids of type Number, not String!

facebook.batch do |batch_api|
  ids.each do |id|
    batch_api.get_object(id, fields: 'first_name, last_name, email') # This will cause exception BatchOperation#to_batch_params when calling response[:relative_url] += (@url ... in line 55 
  end
end

From the documentation GraphAPIMethods#get_object accepts a number or string for the ID parameter but the parameter handling in BatchOperations isn't aware of this.

For now we are working around this issue by calling to_s on the id before passing it to #get_object.

We are using koala gem v3.0.