Coder Social home page Coder Social logo

fb_graph's Introduction

FbGraph

A full-stack Facebook Graph API wrapper in Ruby.

<img src=“https://secure.travis-ci.org/nov/fb_graph.png” />

This gem is deprecated

FbGraph is basically developed for Graph API v1.0, and could be buggy with v2.+.

Since Graph API v1.0 is shut down on 2014/04/30, this gem is also deprecated.

Please use fb_graph2 gem instead. github.com/nov/fb_graph2

Installation

gem install fb_graph

Resources

Examples

Now FbGraph supports all objects listed here: developers.facebook.com/docs/reference/api/ Almost all connections for each object are also supported. (“attachments” and “shares” connections of message object are not supported yet)

You can also play with a Rails sample app here. fbgraphsample.heroku.com/

See GitHub wiki for more examples. github.com/nov/fb_graph/wiki

GET

Basic Objects

user = FbGraph::User.me(ACCESS_TOKEN)

user = FbGraph::User.fetch('matake')
user.name    # => 'Nov Matake'
user.picture # => 'https://graph.facebook.com/matake/picture'

# fb_graph doesn't access to Graph API until you call "fetch"
user = FbGraph::User.new('matake', :access_token => YOUR_ACCESS_TOKEN)
user.identifier # => "matake"
user.name # => nil
user.link # => nil
user = user.fetch
user.name # => "Nov Matake"
user.description # => "http://www.facebook.com/matake"

page = FbGraph::Page.fetch('smartfmteam')
page.name     # => 'smart.fm'
page.picture  # => 'https://graph.facebook.com/smart.fm/picture'

:

Connections

# Public connections
user = FbGraph::User.fetch('matake')
user.feed
user.posts
user.friends
user.tagged
user.family
:

# Private connections requires "access_token"
FbGraph::User.new('matake').friends # => raise FbGraph::Unauthorized
user = FbGraph::User.fetch('matake', :access_token => ACCESS_TOKEN)
user.albums
user.events
user.friends
user.likes
:

# "home" connection is only available for "me"
me = User.new('me', :access_token => ACCESS_TOKEN)
me.home
:

By default, FbGraph will only return the default fields. In order to get a non-default field, you have to supply the connect with an optional hash specifying the field. An example for events:

user.events({:fields => "owner,name,description,picture"}) # { and } optional

An overview of which fields you can include in the graph API can be found at developers.facebook.com/docs/reference/api/, which has a description of the specific objects fields in the sidebar under “Objects”.

# all objects
FbGraph::Searchable.search("FbGraph") # => Array of Hash

# specify type
FbGraph::Page.search("FbGraph") # => Array of FbGraph::Page
FbGraph::User.search("matake", :access_token => ACCESS_TOKEN) # => Array of FbGraph::User

Pagination

# collection
user = FbGraph::User.new('matake', :access_token => ACCESS_TOKEN)
likes = user.likes # => Array of FbGraph::Like
likes.next         # => Array of FbGraph::Like (next page)
likes.previous     # => Array of FbGraph::Like (previous page)
likes.collection.next     # => Hash for pagination options (ex. {"limit"=>"25", "until"=>"2010-08-08T03:17:21+0000"})
likes.collection.previous # => Hash for pagination options (ex. {"limit"=>"25", "since"=>"2010-08-08T06:28:20+0000"})
user.likes(likes.collection.next)     # => same with likes.next
user.likes(likes.collection.previous) # => same with likes.previous

# search results
results = FbGraph::Page.search("FbGraph") # => Array of FbGraph::Page
results.next     # => Array of FbGraph::Page (next page)
results.previous # => Array of FbGraph::Page (next page)
results.klass    # => FbGraph::Page
results.collection.next     # => Hash for pagination options (ex. {"limit"=>"25", "until"=>"2010-08-08T03:17:21+0000"})
results.collection.previous # => Hash for pagination options (ex. {"limit"=>"25", "since"=>"2010-08-08T06:28:20+0000"})
results.klass.search(results.query, results.collection.next)     # => same with results.next
results.klass.search(results.query, results.collection.previous) # => same with results.previous

POST

Update status (wall post)

me = FbGraph::User.me(ACCESS_TOKEN)
me.feed!(
  :message => 'Updating via FbGraph',
  :picture => 'https://graph.facebook.com/matake/picture',
  :link => 'https://github.com/nov/fb_graph',
  :name => 'FbGraph',
  :description => 'A Ruby wrapper for Facebook Graph API'
)

Post a like/comment to a post

post = FbGraph::Page.new(117513961602338).feed.first
bool = post.like!(
  :access_token => ACCESS_TOKEN
)
comment = post.comment!(
  :access_token => ACCESS_TOKEN,
  :message => 'Hey, I\'m testing you!'
)

Post a note

page = FbGraph::Page.new(117513961602338)
note = page.note!(
  :access_token => ACCESS_TOKEN,
  :subject => 'testing',
  :message => 'Hey, I\'m testing you!'
)
me = FbGraph::User.me(ACCESS_TOKEN)
link = me.link!(
  :link => 'https://github.com/nov/fb_graph',
  :message => 'A Ruby wrapper for Facebook Graph API.'
)

Create Event, respond to it

me = FbGraph::User.me(ACCESS_TOKEN)
event = me.event!(
  :name => 'FbGraph test event',
  :start_time => 1.week.from_now,
  :end_time => 2.week.from_now
)
bool = event.attending!(
  :access_token => ACCESS_TOKEN
)
bool = event.maybe!(
  :access_token => ACCESS_TOKEN
)
bool = event.declined!(
  :access_token => ACCESS_TOKEN
)

Create an album

me = FbGraph::User.me(ACCESS_TOKEN)
album = me.album!(
  :name => 'FbGraph test',
  :message => 'test test test'
) # => now facebook Graph API returns weird response for this call

Upload a photo to an album

me = FbGraph::User.me(ACCESS_TOKEN)
album = me.albums.first
album.photo!(
  :access_token => ACCESS_TOKEN,
  :source => File.new('/Users/nov/Desktop/nov.gif', 'rb'), # 'rb' is needed only on windows
  :message => 'Hello, where is photo?'
)

DELETE

Delete an object

post = FbGraph::Page.new(117513961602338).feed.first
bool = post.like!(
  :access_token => ACCESS_TOKEN
)
comment = post.comment!(
  :access_token => ACCESS_TOKEN,
  :message => 'Hey, I\'m testing you!'
)
comment.destroy(:access_token => ACCESS_TOKEN)
post.unlike!(:access_token => ACCESS_TOKEN)
post.destroy(:access_token => ACCESS_TOKEN)

Authentication

Both Facebook JavaScript SDK and normal OAuth2 flow are supported. Below I show simple sample code. You can also see github.com/nov/fb_graph_sample for more details Rails3 sample application.

In addition, if you are migrating an application that uses old-style session keys you can exchange the keys for access tokens. See more here: developers.facebook.com/docs/authentication/fb_sig/

JavaScript SDK

fb_auth = FbGraph::Auth.new(YOUR_APP_ID, YOUR_APPLICATION_SECRET)
fb_auth.client # => Rack::OAuth2::Client

# get Facebook's auth cookie in advance using their JS SDK
fb_auth.from_cookie(cookies)
fb_auth.access_token # => Rack::OAuth2::AccessToken
fb_auth.user         # => FbGraph::User (only basic attributes)
fb_auth.user.fetch   # => fetch more details

Normal OAuth2 Flow

# setup client
client = fb_auth.client
client.redirect_uri = "http://your.client.com/facebook/callback"

# redirect user to facebook
redirect_to client.authorization_uri(
  :scope => [:email, :read_stream, :offline_access]
)

# in callback
client.authorization_code = params[:code]
access_token = client.access_token! :client_auth_body # => Rack::OAuth2::AccessToken
FbGraph::User.me(access_token).fetch # => FbGraph::User

Extend Access Token Lifetime

# setup client
fb_auth = FbGraph::Auth.new(YOUR_APP_ID, YOUR_APPLICATION_SECRET)
fb_auth.exchange_token! 'short-life-access-token'
fb_auth.access_token # => Rack::OAuth2::AccessToken

Analytics

app = FbGraph::Application.new(YOUR_APP_ID, :secret => YOUR_APPLICATION_SECRET)
app.insights # => Array of FbGraph::Insight

Test User

Not tested well yet. Sample is here. gist.github.com/752974

FQL

Not tested well yet. Sample is here. gist.github.com/752914

More Examples?

See GitHub wiki for more examples. github.com/nov/fb_graph/wiki

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 nov matake. See LICENSE for details.

fb_graph's People

Contributors

agerlic avatar al2o3cr avatar alagu avatar bibstha avatar chrisdurtschi avatar clemens avatar douwem avatar ened avatar gazay avatar gr8bit avatar jacobh0 avatar jbyck avatar jgorset avatar kayloos avatar kellym avatar kemper avatar kevinzen avatar kukunin avatar mahkhaled avatar marcroberts avatar mdw123 avatar micahwedemeyer avatar nov avatar paulodelgado avatar pfeiffer avatar raelik avatar recurser avatar spiceee avatar tmlee avatar wjbuys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fb_graph's Issues

insights options?

Hi Nov ,
i want to try implement the page_like_adds , page_wall_posts and other
http://developers.facebook.com/docs/reference/fql/insights#Metrics of insights , can you point out which part of the source should I look into? Is it I need to open a new file in connection folder? And create a new class , just like likes class , photo class? Or I should put it inside the option of insights?

Lol , the last issue I posted .... you are really fast and nice work!

example
https://graph.facebook.com/108690469197928/insights/page_like_adds?access_token=133478993377540|f704be0f36e093142b38dc94-561173731|108690469197928|linQ5L9E7UTTozawLJhyOOKZnhQ

Page insights?

I have found that FbGraph::Page didn't have any insights. Is it true?

writing tests for these apps?

Hey, I'm trying to write some tests for an app that uses this gem... Specifically, the sample app doesn't have tests showing how test functionality that is behind a user log-in

Basically I need a pattern to write a simple controller test, but it must include authenticating the user first (because what I'm testing requires that the user be logged in to access the given resources)

basically I want a way to mock a user -- not sure how/if this is gonna work with Oauth. Note that I don't actually need to test the Oauth log-in, nor do I need to actually log the user in at all (in fact a test runner would have a hard time doing this)-- I just need an object that looks and acts like a logged-in facebook object.

So I want to call something like this:
authenticate Facebook.identify(auth.user)

Then I want the test DB records to be created & setup as if there is a real logged-in user. I'd be happy to by-pass some of the functions in facebooks_controller.rb (see sample app) - don't need to actually get a real token or do the real Oauth dance, just need to create a mocked current_user that behaves like a real user for the test cases.

Any advice?

Trying to download information of one Photo

Hi, this is my code:

picture = FbGraph::Photo.new(id, :access_token => user.current_auth_token).fetch

Unluckily this breaks with error message:

Unsupported get request.

Is this a bug or something not supported? I was guessing it is supported as the methods are available..

Thx

FbGraph photos connection problem

hi,

I have got a problem with rails FbGraph libary. I'd like to call connection object named photos and get picture (attribute picture) from facebook.
this is my test code:

Controler:

def show
@user = current_user.profile.photos
end

View:
<% @user.each do |post1| %>
<%= post1.pictures %>
<% end %>

I get a blank result in my View. I'm wonder what's wrong.
Thanks for help...

Pushin Photos to an album

Hey you all

I try to push photos to an existing album - it used to work, but now its broken, and fb_graph throws exception FbGraph::Exception ((#120) Invalid album id). The workflow is:

  1. I create an album and I get the identifier from the facebook (fb_graph) response
  2. I use the same identifier with method photo!

As you see, quite simple. Do you have any idea why this is broken or is it a facebook issue?

OAuth2::HTTPError on #create

I am using the latest fb_graph and fb_graph_sample code and getting an error in the create action.

OAuth2::HTTPError (Received HTTP 400 during request.):
app/controllers/facebook_controller.rb:33:in 'create'

That is this line of code:
access_token = Facebook.auth.client.web_server.get_access_token(
params[:code],
:redirect_uri => callback_facebook_url
)

Untitled

Hi can you halp me please with the tagging ?
I'm trying to tag someone on the photo that I've uploaded whith :

tags = [{:id=>session[:myid]},{:name=>"nome"},{:x=>50},{:y=>50}]
pp photo = me.photo!(:name => 'foto di prova', :source => file, :tags=>tags)

and I have the error : (#100) Invalid parameter

FbGraph Exception when posting to feed

Hey, I have fb_graph set up with devise/omniauth, the token for the user is saved in the database and I can fetch data and upload images, but I can't seem to be able to post to my feed. The permissions I have : 'offline_access, email, user_photos, user_checkins' and here is the error I get :

ruby-1.9.2-p136 :161 > User.last.fb_get_data
FbGraph::Exception: FbGraph::Exception
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/fb_graph-1.3.5/lib/fb_graph/node.rb:121:in `rescue in handle_response'
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/fb_graph-1.3.5/lib/fb_graph/node.rb:87:in `handle_response'
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/fb_graph-1.3.5/lib/fb_graph/node.rb:46:in `post'
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/fb_graph-1.3.5/lib/fb_graph/connections/feed.rb:83:in `feed!'
from /home/n0va/projects/karma/app/models/user.rb:46:in `fb_get_data'
from (irb):161
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from /home/n0va/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

And the code I used :
me = FbGraph::User.me(self.token)
me.feed!(
:message => 'Updating via FbGraph',
:picture => 'https://graph.facebook.com/matake/picture',
:link => 'http://github.com/nov/fb_graph',
:name => 'FbGraph',
:description => 'A Ruby wrapper for Facebook Graph API'
)

Comment Count Not Returned

Comment counts are not returned for posts. I'm able to get the number of likes for a Post with:

my_post.like_count["count"]

but I don't see anything returned for comments.

Accessing FB via Lib task Offline

Awesome Gem!!! (First off)

I am trying to access user data in a timed task and have offline_access granted. I started the project via the fbgraph sample app and am using an iframed canvas app to deal with user interaction. I have a timed task in my library that I want to run fql queries within against users (Facebooks) stored in my db. I see that the sample app stores the access_token, so how can I access (instantiate) an authenticated session offline?

Thanks.

Fail when parsing dates

Dates in founded in facebook pages can be just a year etc. So on pages when founded isn't a valid date the parser fails.
File 'lib/fb_graph/page.rb'
Line 28

Should rescue or something.
ActionView::Template::Error (invalid date):

/usr/lib/ruby/1.8/date.rb:956:in 'new_by_frags' /usr/lib/ruby/1.8/date.rb:1000:in 'parse' fb_graph (0.8.0) lib/fb_graph/page.rb:27:in 'initialize' fb_graph (0.8.0) lib/fb_graph/node.rb:16:in 'new' fb_graph (0.8.0) lib/fb_graph/node.rb:16:in 'fetch' fb_graph (0.8.0) lib/fb_graph/node.rb:20:in 'fetch'

Doesn't work outside of Rails

Appears to have activesupport dependencies.

irb(main):007:0> user = FbGraph::User.fetch("moot")
NoMethodError: undefined method blank?' for :get:Symbol from /usr/lib/ruby/gems/1.8/gems/fb_graph-0.1.0/lib/fb_graph/node.rb:61:inbuild_endpoint'
from /usr/lib/ruby/gems/1.8

Question: Fetch friends w/ Birthdays...

Hi Nov,

I'm curious how to fetch friends and include the birthdays and maybe other columns I am looking for. Also, what kind of data set is returned (FbGraph User objects or just the JSON from FB?)

Thanks.

Create Test Users

Are there any methods to easily create test users using fb_graph?

uninitialized constant

I am calling fb_graph from within my User model to update some fields before saving.

I am getting an 'uninitialized constant User::FBGraph' error when I do so. I am using Rails 3. I have the gemfile asking for 'fb_graph' but I don't know if there's something else I need to do to set this up and avoid this problem. Any suggestions?

home not working

im trying to access the home module, there seems to be a problem within post since e.g. fbgraphuser.connection(:home) works

TypeError: can't convert Symbol into String
from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/user.rb:66:in delete' from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/user.rb:66:ininitialize'
from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/post.rb:24:in new' from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/post.rb:24:inblock in initialize'
from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/post.rb:20:in each' from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/post.rb:20:ininitialize'
from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/connections/home.rb:7:in new' from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/connections/home.rb:7:inblock in home'
from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/connections/home.rb:6:in map!' from /Volumes/data/home/yannick/.rvm/gems/ruby-1.9.2-preview3/gems/fb_graph-1.0.7/lib/fb_graph/connections/home.rb:6:inhome'
from (irb):27

Not able to comment to a post on a page wall anymore

Hello
Have this code that worked a few days ago, but doesn't work anymore:
post = FbGraph::Post.new(entry.entry_id)
post.comment!(
:access_token => account.accessToken,
:message => message
)

I get this error 210 User not visible

But again, I can post a message on the wall without problem ...

Any idea?

FbGraph should depend on a specific version of rest-client

We ran into an issue where our system had the 1.2.x version of rest-client installed and we installed fb_graph.

With 1.2.x the response objects don't have a body method, so we saw a large number of exceptions like:

undefined method `body' for #<RestClient::Response:0x2b1e7c3037f0>

Installing 1.4.x fixed our issues.

Cannot install fb_graph GEM

% sudo gem install -V fb_graph
GET http://rubygems.org/latest_specs.4.8.gz
302 Found
GET http://production.s3.rubygems.org/latest_specs.4.8.gz
304 Not Modified
GET http://rubygems.org/quick/Marshal.4.8/restclient_with_cert-0.0.1.gemspec.rz
302 Found
GET http://production.cf.rubygems.org/quick/Marshal.4.8/restclient_with_cert-0.0.1.gemspec.rz
404 Not Found
Error fetching remote data:     bad response Not Found 404 (http://production.cf.rubygems.org/quick/Marshal.4.8/restclient_with_cert-0.0.1.gemspec.rz)
Falling back to local-only install
Installing gem fb_graph-1.6.3
ERROR:  Error installing fb_graph:
    fb_graph requires restclient_with_cert (>= 0, runtime)

Does that have anything to do with the gem specs in the project?

Tagged returns only one post?

This is copied from the last comment of this thread.
https://github.com/nov/fb_graph/issues/closed#issue/16

fb_auth = Facebook.auth
identifier = Facebook.find(:first).identifier
user = FbGraph::User.new(identifier, :access_token => fb_auth.access_token).fetch
@feed = user.feed
@tagged = user.tagged
puts @tagged

user.tagged only returns one post.
when I go thourgh graph.facebook.com/#{identifier}/tagged I get at least five posts.

Determine Granted Permissions?

Great gem BTW, loving it.

I have different levels of permissions for users, and before I take an action need to determine what a given user has authorized thus far. is there a way to query that using fb_graph? thanks!

Error when fetching feed

Running this code:

@page = FbGraph::Page.new(acc.page_id)
feed= @page.feed(:access_token => acc.accessToken)

and get this error:

Symbol as array index
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/collection.rb:7:in `[]'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/collection.rb:7:in `initialize'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/post.rb:47:in `new'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/post.rb:47:in `initialize'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/connections/feed.rb:33:in `new'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/connections/feed.rb:33:in `feed'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/connections/feed.rb:32:in `map!'
/Users/thomas/.rvm/gems/ruby-1.8.7-p299/gems/fb_graph-1.0.3/lib/fb_graph/connections/feed.rb:32:in `feed'
/Users/thomas/Sites/MySite/lib/facebook.rb:9:in `update'

Any idea?

Can't make authentication work

Hello everyone, I am using Rails 3.0.4 and using this gem to get authenticated with facebook. Everything I want to use from Facebook is the ability to post to the Wall. So, for example: A user likes a product, he clicks on a link, the JS SDK makes that pop-up appear, the user login and authorizes the app and then a message is posted to the user's wall. However I am having troubles.

I got to the developer page on Facebook and get set the Site URL to "http://myapp.heroku.com/" and the Site Domain to "heroku.com" 'cause I push the app to heroku in order to test it.

Configure the facebook.yml file with the proper id/key/secret.

After pushing the app to heroku and clicking login, the pop-up appears, I login and then I get a 500 Error message at http://myapp.heroku.com/facebook.

There is something still more strange. Even when I just grab the fb_graph_sample app and just get new id/key/secret and set the url and domain, the same error keeps happening.

Any ideas on how to solve it? Please!

Some weird errors

Hi,
After a month without any problems, suddenly I get three different errors.
#<NoMethodError: undefined method []' for nil:NilClass> /usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:21:in initialize'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:20:ineach' /usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:20:in initialize'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:33:innew' /usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:33:in feed'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:32:inmap!' /usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:32:in feed'
/data/[...]/lib/facebook.rb:11:inupdate' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in each'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in**send**' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in each'
/data/[...]/lib/facebook.rb:8:inupdate' /data/[...]/lib/facebook.rb:4:in each'
/data/[...]/lib/facebook.rb:4:inupdate' /data/[...]/lib/tasks/facebook.rake:7 /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in`load'
/usr/bin/rake:19

#<TypeError: can't convert Symbol into String>
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/user.rb:66:in `delete'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/user.rb:66:in `initialize'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:24:in `new'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:24:in `initialize'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:20:in `each'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/post.rb:20:in `initialize'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:33:in `new'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:33:in `feed'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:32:in `map!'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:32:in `feed'
/data/[...]/lib/facebook.rb:11:in `update'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in `each'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in `__send__'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in `each'
/data/[...]/lib/facebook.rb:8:in `update'
/data/[...]/lib/facebook.rb:4:in `each'
/data/[...]/lib/facebook.rb:4:in `update'
/data/[...]/lib/tasks/facebook.rake:7
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19


#<FbGraph::Exception: FbGraph::Exception>
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/node.rb:118:in `handle_response'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/node.rb:38:in `get'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/node.rb:24:in `connection'
/usr/lib/ruby/gems/1.8/gems/fb_graph-1.0.4/lib/fb_graph/connections/feed.rb:31:in `feed'
/data/[...]/lib/facebook.rb:11:in `update'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in `each'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in `__send__'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.0/lib/active_record/relation.rb:13:in `each'
/data/[...]/lib/facebook.rb:8:in `update'
/data/[...]/lib/facebook.rb:4:in `each'
/data/[...]/lib/facebook.rb:4:in `update'
/data/[...]/lib/tasks/facebook.rake:7
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

All of them are coming after @page = @page.feed(:access_token => acc.accessToken)

Any idea?

Thanks, Terw

Small typo in RDoc

Within ALBUM documentation.

FbGraph::album.fetch(ALBUM_ID, :access_token => ACCESS_TOKEN)
should be
FbGraph::Album.fetch(ALBUM_ID, :access_token => ACCESS_TOKEN)

How to Post to Friends Wall?

Hi,

Commented on another (closed) thread... Trying to figure out how I can post a message to a friends wall. My user has granted publish_stream. Thanks!

Integration with Kaminari for Pagination

Hi,

A customer requests to page through the photos / albums of a user. I don't want to invent another new pagination module, so I tried to extend fb_graph with kaminaris pagination methods.

So far this is not very successful. I.e. I tried:

in a config/initializers/ext_fb_graph.rb

require 'kaminari'

module FbGraph
  class Connection
    per_page 10
  end
end

So far this cannot work as per_page is unresolved. I will try more though.

And also, I'm not sure if this is the right channel to ask this question. Please delete or forward me to a right source. :-)

Can't fetch friend data...

Trying to fetch a user's friend's location, and I'm only receiving the basic profile information. Do I need to do anything special? My application has the friends_location permission. Are there any ways to debug/verify access?

FbGraph::User.new(id_or_name, :access_token => token).fetch

Error initializing posts

I have a production app which was running v1.0.4 beautifully. A few days back, the following exception started popping up. I updated to 1.0.6 thinking I missed an update, problem still exists. I am going to investigate on my end but I wanted to bring it to your attention as well. Any help you can provide is appreciated. Details follow:

Exception Stack

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

/opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/post.rb:21:in initialize' /opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/post.rb:20:ineach'
/opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/post.rb:20:in initialize' /opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/connections/posts.rb:7:innew'
/opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/connections/posts.rb:7:in posts' /opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/connections/posts.rb:6:inmap!'
/opt/local/lib/ruby/gems/1.8/gems/fb_graph-1.0.6/lib/fb_graph/connections/posts.rb:6:in `posts'

Calling Code (Modified For This Post)

def facebook_posts
#begin
post_count = 3
posts = FbGraph::Page.fetch('[group name here]').posts.slice(0, post_count)
#rescue
# posts = Array.new
#end
end

Bug in node.rb, line 75?

When invoking search like
result = FbGraph::User.search( search_criteria, :access_token => @access_token )
I get a "Error validating application." Exception.
Looks like line 75 requires the following fix:
"if params_[:access_token].is_a?(OAuth2::AccessToken)"

Bug with session in Safari 5.0.3

After pushing the button "Start" in "Normal OAuth flowI" block i'm redirected to 'Request for permission'. Then after pushing "Allow" button i'm redirected to 'Facebook Login' page.

Create Event problem

I'm trying to create an event similar to example of documentation.

But, it's not working.

ree-1.8.7-2011.03 :003 > event = me.event!( :name => 'FbGraph test event', :start_time => 1.week.from_now.to_i, :end_time => 2.week.from_now.to_i)
FbGraph::Exception: FbGraph::Exception
from /home/lucas/.rvm/gems/ree-1.8.7-2011.03/gems/fb_graph-1.5.3/lib/fb_graph/node.rb:121:in handle_response' from /home/lucas/.rvm/gems/ree-1.8.7-2011.03/gems/fb_graph-1.5.3/lib/fb_graph/node.rb:46:inpost'
from /home/lucas/.rvm/gems/ree-1.8.7-2011.03/gems/fb_graph-1.5.3/lib/fb_graph/connections/events.rb:14:in `event!'

Walking connections requires specifying your access token again

When walking connections with fb graph, you have to specify your access_token or it won't be sent to facebook. For example the following code won't work:

current_user.facebook_graph.albums.each do |album|
  album.photos.each do |photo|

You have to use:

current_user.facebook_graph.albums.each do |album|
  album.photos(:access_token=>current_user.fb_access_token).each do |photo|

Ideally you'd only have to specify this when creating the FbGraph::User, everything else would be passed along 'magically'

OpenSSL::SSL::SSLError

When my application regains control after logging in via Facebook, this error is thrown:

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):

and login fails.

I'm using rails 3.0.6 and fb_graph 1.6.5

Upload photo working?

Hi Nov,

Thankyou for creating this. I'm playing around with it and get a 'internal server error' from the Facebook API when I try to upload a photo to an album. It works via curl with the same album id and the same auth token, so I wanted to know if this functionality works for you.

Thanks,

-- Andy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.