I am trying to get the facbeook API to work. I am using Koala, OmniAuth-Facebook, and Devise. I am trying to get the feed from a facebook group. I can get the posts of the facebook account, but I just get [] from the facebook group’s feed.
#posts_controller.rb
class PostsController < ApplicationController
require 'koala'
def home
end
def index
@graph = Koala::Facebook::API.new('EAAEsRUgaygUBAGrJm9af4NAroK2zafwoVjtl9czVVqvfEDlLq2VV8LQChtBDHmrqQTS3119cSz8u1rEv4LrF5wXKIHC4CJGgUY8yiCQumYzLaDRTELTaj7vzQV9tZAuFDy5GQVYRnspIv17sGIFZA2uVkIZB2I5vLFaI0OFQQkdidT9lho75IfhkRk7xM6pLKB8KkwXTBsZBs4rbi8YXfkebI2yNVyHHRFH5p6u8NgZDZD')
end
end`
and
#index.html.erb
<%= @graph.get_connection('me', 'posts', {
limit: 5,
fields: ['message', 'id']}) %>
<%= @graph.get_connection('14117761406', 'feed', {
limit: 5,
fields: ['message', 'id']}) %>
The first block prints out: [{“message”=>”test 1”, “id”=>”106211743505945_106214170172369”}]
But the second block just prints [].
2
Answers
Figured it out.
I was using get_connection instead of get_object, so it was trying to get a list of things I was posting in that group (nothing).
this code works.
Second, when using test users, feeds in groups don't show up. So even though I tested get_object before, it wasn't working with the test users. I switched to my profile and it is working now.
you should do some R&D in console (
rails c
) then write your code. It will help you figure what happen to object, inspect them …Also check out
pry
gem