Comments (3)
Hey Nerian,
I'm actually not that familiar with JSON.pretty_generate. get_object returns a hash, whereas get_connection returns an Array (actually a GraphCollection < Array), which has to be the source of the difference. If you're still having the problem (sorry about the delay in getting back to you!) can you send me the backtrace from the error, and I'll try to track it down? (I'm curious now.)
Thanks!
Alex
from koala.
Hi Alex,
No problem :) I used facebook_oauth where there was a conflict, but it would be much better to just use koala :)
In order to reproduce the issue you can just open a rails console:
ruby-1.9.2-p180 :010 > graph = Koala::Facebook::GraphAPI.new('2227470867|2.ZLyg_CgA867kqMpt2ElbTw__.3600.1305219600.0-100000024399383|3AHpb63iBhifIcb6v2SDpREW6t4')
=> #<Koala::Facebook::GraphAPI:0x00000101d58c50 @access_token="2227470867|2.ZLyg_CgA867kqMpt2ElbTw__.3600.1305219600.0-100000024399383|3AHpb63iBhifIcb6v2SDpREW6t4">
ruby-1.9.2-p180 :016 > puts JSON.pretty_generate(graph.get_connections('me', 'friends'))
NoMethodError: undefined method `merge' for #<JSON::Ext::Generator::State:0x00000101c9cbe0>
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/activesupport-3.0.7/lib/active_support/json/encoding.rb:61:in `options_for'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/activesupport-3.0.7/lib/active_support/json/encoding.rb:46:in `block in encode'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/activesupport-3.0.7/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/activesupport-3.0.7/lib/active_support/json/encoding.rb:45:in `encode'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/activesupport-3.0.7/lib/active_support/json/encoding.rb:30:in `encode'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/activesupport-3.0.7/lib/active_support/core_ext/object/to_json.rb:20:in `to_json'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/json-1.5.1/lib/json/common.rb:266:in `generate'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/json-1.5.1/lib/json/common.rb:266:in `pretty_generate'
from (irb):16
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
from /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@goofb/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
JSON.pretty_generate expects a hash like object. I think the solution is to define the method to_hash in Koala::Facebook::GraphCollection. Basically instead of returning an array of hashes, return a hash with an array of hashes.
The generate method api:
http://ruby-doc.org/ruby-1.9/classes/JSON.html#M006170
from koala.
Hey Norian,
Thanks for the update. It's strange that pretty_generate doesn't support arrays, since arrays are valid JSON just as much as hashes. While we can't change what the gem returns (that would break all the apps that use Koala, plus returning an array makes more sense for most cases), you should be easily able to wrap the array in a hash before calling pretty_generate.
Let me know if that works, and if we can help with anything else!
Best,
Alex
from koala.
Related Issues (20)
- Page Access Token Error? HOT 6
- Testing with Koala fail by execution expired HOT 1
- put_video not showing on wall, but shows in videos library.
- fbtrace_id is not passed correctly to Koala::Error
- Unable to post visitor post to a facebook page using graph API. HOT 2
- Hellpp HOT 3
- Undefined Method "alias_method_chain" HOT 1
- Graph API v2.8 is going to be Deprecated on Apr 18, 2019. HOT 2
- Facebook deprecated befriend API from v4.0
- Koala::Facebook::ServerError on requesting for higher limit of IG posts HOT 2
- NoMethodError (undefined method `scheme' for "https://graph.facebook.com":String): HOT 2
- please update the graph_collection, the next_page & previous_page are not working HOT 2
- Koala breaks with faraday 2.0 release `File does not exist: net/http/post/multipart` HOT 5
- How to post a content to my group on Facebook ? HOT 1
- GraphErrorChecker#response_hash returns nil causing gem to crash HOT 3
- Facing Koala::Facebook::OAuthTokenRequestError when fetching app_access_token HOT 6
- Not compatible with faraday-net_http_persistent
- Extra maintainership HOT 2
- Tagging incorrect? HOT 2
- Getting "OAuthException, code: 200, message: (#200) Permissions error" while requesting ad_insights GraphAPI.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koala.