arsduo / koala

A lightweight Facebook library supporting the Graph, Marketing, and Atlas APIs, realtime updates, test users, and OAuth.
http://developers.facebook.com/
MIT License
3.56k stars 464 forks source link

GraphCollection.next_page method doesn't accept api_version as parameter #526

Open ashishKAgg opened 8 years ago

ashishKAgg commented 8 years ago

GraphCollection.next_page method doesn't accept api_version as parameter. Whenever user perform next_page for /album endpoint, then it returns erroneous value for cover_photo field. Steps to replicate: 1) Fetch albums for a page which contains more than 50 albums for api_version 2.6. Fetch following album fields: id,cover_photo. 2) Response will contain cover_photo value in JSON format. Also, Response will contain paging information along with next url. 3) Call next_page method on response will return next page albums. However, in this response cover_photo JSON would become string rather than JSON.

arsduo commented 7 years ago

Interesting! That's a good catch. I take it there are cases where you might want to use a specific API version for next_page but not to set it for the API as a whole?

sdsunjay commented 6 years ago

I am also running into this issue with the Facebook API. Since setting the API version, the following code no longer works:

   def add_movies
     @graph = Koala::Facebook::API.new(access_token)
     @movies = @graph.get_object('me?fields=movies', {}, api_version: 'v3.1')
     puts @movies
     loop do
       break if @movies.blank?

       help_add_movies
       puts @movies.class
       @movies = @movies.next_page
     end
   end

I get NoMethodError (undefined method 'next_page' for #<Hash:0x00007ff18b6a57c8>). Is there a work around or do I need to remove the api version?