{"id":13747559,"url":"https://github.com/nov/fb_graph","last_synced_at":"2025-05-14T15:09:32.600Z","repository":{"id":880258,"uuid":"624940","full_name":"nov/fb_graph","owner":"nov","description":"This gem doesn't support FB Graph API v2.0+. Please use fb_graph2 gem instead.","archived":false,"fork":false,"pushed_at":"2022-06-25T00:58:44.000Z","size":2706,"stargazers_count":1033,"open_issues_count":0,"forks_count":187,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-11T15:56:55.108Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nov.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"nov"}},"created_at":"2010-04-23T07:15:16.000Z","updated_at":"2025-01-02T01:12:33.000Z","dependencies_parsed_at":"2022-07-14T21:00:38.868Z","dependency_job_id":null,"html_url":"https://github.com/nov/fb_graph","commit_stats":null,"previous_names":[],"tags_count":189,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nov%2Ffb_graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nov%2Ffb_graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nov%2Ffb_graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nov%2Ffb_graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nov","download_url":"https://codeload.github.com/nov/fb_graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254170046,"owners_count":22026219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T06:01:33.524Z","updated_at":"2025-05-14T15:09:32.546Z","avatar_url":"https://github.com/nov.png","language":"Ruby","readme":"= FbGraph\n\nA full-stack Facebook Graph API wrapper in Ruby.\n\n{\u003cimg src=\"https://secure.travis-ci.org/nov/fb_graph.png\" /\u003e}[http://travis-ci.org/nov/fb_graph]\n\n== This gem is deprecated\n\nFbGraph is basically developed for Graph API v1.0, and could be buggy with v2.+.\n\nSince Graph API v1.0 is shut down on 2014/04/30, this gem is also deprecated.\n\nPlease use fb_graph2 gem instead.\nhttps://github.com/nov/fb_graph2\n\n== Installation\n\n  gem install fb_graph\n\n== Resources\n\n* View Source on GitHub (https://github.com/nov/fb_graph)\n* Report Issues on GitHub (https://github.com/nov/fb_graph/issues)\n* Subscribe Update Info (https://www.facebook.com/FbGraph)\n* Q\u0026A on Google Groups (http://groups.google.com/group/fb_graph)\n\n== Examples\n\nNow FbGraph supports all objects listed here: http://developers.facebook.com/docs/reference/api/\nAlmost all connections　for each object are also supported. (\"attachments\" and \"shares\" connections of message object are not supported yet)\n\nYou can also play with a Rails sample app here. http://fbgraphsample.heroku.com/\n\nSee GitHub wiki for more examples.\nhttps://github.com/nov/fb_graph/wiki\n\n=== GET\n\n==== Basic Objects\n\n  user = FbGraph::User.me(ACCESS_TOKEN)\n\n  user = FbGraph::User.fetch('matake')\n  user.name    # =\u003e 'Nov Matake'\n  user.picture # =\u003e 'https://graph.facebook.com/matake/picture'\n\n  # fb_graph doesn't access to Graph API until you call \"fetch\"\n  user = FbGraph::User.new('matake', :access_token =\u003e YOUR_ACCESS_TOKEN)\n  user.identifier # =\u003e \"matake\"\n  user.name # =\u003e nil\n  user.link # =\u003e nil\n  user = user.fetch\n  user.name # =\u003e \"Nov Matake\"\n  user.description # =\u003e \"http://www.facebook.com/matake\"\n\n  page = FbGraph::Page.fetch('smartfmteam')\n  page.name     # =\u003e 'smart.fm'\n  page.picture  # =\u003e 'https://graph.facebook.com/smart.fm/picture'\n\n  :\n\n==== Connections\n\n  # Public connections\n  user = FbGraph::User.fetch('matake')\n  user.feed\n  user.posts\n  user.friends\n  user.tagged\n  user.family\n  :\n\n  # Private connections requires \"access_token\"\n  FbGraph::User.new('matake').friends # =\u003e raise FbGraph::Unauthorized\n  user = FbGraph::User.fetch('matake', :access_token =\u003e ACCESS_TOKEN)\n  user.albums\n  user.events\n  user.friends\n  user.likes\n  :\n\n  # \"home\" connection is only available for \"me\"\n  me = User.new('me', :access_token =\u003e ACCESS_TOKEN)\n  me.home\n  :\n\nBy default, FbGraph will only return the default fields. In order to\nget a non-default field, you have to supply the connect with an optional hash\nspecifying the field. An example for events:\n\n  user.events({:fields =\u003e \"owner,name,description,picture\"}) # { and } optional\n\nAn overview of which fields you can include in the graph API can be found at\nhttps://developers.facebook.com/docs/reference/api/, which has a description\nof the specific objects fields in the sidebar under \"Objects\".\n\n==== Search\n\n  # all objects\n  FbGraph::Searchable.search(\"FbGraph\") # =\u003e Array of Hash\n\n  # specify type\n  FbGraph::Page.search(\"FbGraph\") # =\u003e Array of FbGraph::Page\n  FbGraph::User.search(\"matake\", :access_token =\u003e ACCESS_TOKEN) # =\u003e Array of FbGraph::User\n\n==== Pagination\n\n  # collection\n  user = FbGraph::User.new('matake', :access_token =\u003e ACCESS_TOKEN)\n  likes = user.likes # =\u003e Array of FbGraph::Like\n  likes.next         # =\u003e Array of FbGraph::Like (next page)\n  likes.previous     # =\u003e Array of FbGraph::Like (previous page)\n  likes.collection.next     # =\u003e Hash for pagination options (ex. {\"limit\"=\u003e\"25\", \"until\"=\u003e\"2010-08-08T03:17:21+0000\"})\n  likes.collection.previous # =\u003e Hash for pagination options (ex. {\"limit\"=\u003e\"25\", \"since\"=\u003e\"2010-08-08T06:28:20+0000\"})\n  user.likes(likes.collection.next)     # =\u003e same with likes.next\n  user.likes(likes.collection.previous) # =\u003e same with likes.previous\n\n  # search results\n  results = FbGraph::Page.search(\"FbGraph\") # =\u003e Array of FbGraph::Page\n  results.next     # =\u003e Array of FbGraph::Page (next page)\n  results.previous # =\u003e Array of FbGraph::Page (next page)\n  results.klass    # =\u003e FbGraph::Page\n  results.collection.next     # =\u003e Hash for pagination options (ex. {\"limit\"=\u003e\"25\", \"until\"=\u003e\"2010-08-08T03:17:21+0000\"})\n  results.collection.previous # =\u003e Hash for pagination options (ex. {\"limit\"=\u003e\"25\", \"since\"=\u003e\"2010-08-08T06:28:20+0000\"})\n  results.klass.search(results.query, results.collection.next)     # =\u003e same with results.next\n  results.klass.search(results.query, results.collection.previous) # =\u003e same with results.previous\n\n=== POST\n\n==== Update status (wall post)\n\n  me = FbGraph::User.me(ACCESS_TOKEN)\n  me.feed!(\n    :message =\u003e 'Updating via FbGraph',\n    :picture =\u003e 'https://graph.facebook.com/matake/picture',\n    :link =\u003e 'https://github.com/nov/fb_graph',\n    :name =\u003e 'FbGraph',\n    :description =\u003e 'A Ruby wrapper for Facebook Graph API'\n  )\n\n==== Post a like/comment to a post\n\n  post = FbGraph::Page.new(117513961602338).feed.first\n  bool = post.like!(\n    :access_token =\u003e ACCESS_TOKEN\n  )\n  comment = post.comment!(\n    :access_token =\u003e ACCESS_TOKEN,\n    :message =\u003e 'Hey, I\\'m testing you!'\n  )\n\n==== Post a note\n\n  page = FbGraph::Page.new(117513961602338)\n  note = page.note!(\n    :access_token =\u003e ACCESS_TOKEN,\n    :subject =\u003e 'testing',\n    :message =\u003e 'Hey, I\\'m testing you!'\n  )\n\n==== Post a link\n\n  me = FbGraph::User.me(ACCESS_TOKEN)\n  link = me.link!(\n    :link =\u003e 'https://github.com/nov/fb_graph',\n    :message =\u003e 'A Ruby wrapper for Facebook Graph API.'\n  )\n\n==== Create Event, respond to it\n\n  me = FbGraph::User.me(ACCESS_TOKEN)\n  event = me.event!(\n    :name =\u003e 'FbGraph test event',\n    :start_time =\u003e 1.week.from_now,\n    :end_time =\u003e 2.week.from_now\n  )\n  bool = event.attending!(\n    :access_token =\u003e ACCESS_TOKEN\n  )\n  bool = event.maybe!(\n    :access_token =\u003e ACCESS_TOKEN\n  )\n  bool = event.declined!(\n    :access_token =\u003e ACCESS_TOKEN\n  )\n\n==== Create an album\n\n  me = FbGraph::User.me(ACCESS_TOKEN)\n  album = me.album!(\n    :name =\u003e 'FbGraph test',\n    :message =\u003e 'test test test'\n  ) # =\u003e now facebook Graph API returns weird response for this call\n\n==== Upload a photo to an album\n\n  me = FbGraph::User.me(ACCESS_TOKEN)\n  album = me.albums.first\n  album.photo!(\n    :access_token =\u003e ACCESS_TOKEN,\n    :source =\u003e File.new('/Users/nov/Desktop/nov.gif', 'rb'), # 'rb' is needed only on windows\n    :message =\u003e 'Hello, where is photo?'\n  )\n\n=== DELETE\n\n==== Delete an object\n\n  post = FbGraph::Page.new(117513961602338).feed.first\n  bool = post.like!(\n    :access_token =\u003e ACCESS_TOKEN\n  )\n  comment = post.comment!(\n    :access_token =\u003e ACCESS_TOKEN,\n    :message =\u003e 'Hey, I\\'m testing you!'\n  )\n  comment.destroy(:access_token =\u003e ACCESS_TOKEN)\n  post.unlike!(:access_token =\u003e ACCESS_TOKEN)\n  post.destroy(:access_token =\u003e ACCESS_TOKEN)\n\n=== Authentication\n\nBoth Facebook JavaScript SDK and normal OAuth2 flow are supported.\nBelow I show simple sample code.\nYou can also see https://github.com/nov/fb_graph_sample for more details Rails3 sample application.\n\nIn addition, if you are migrating an application that uses old-style session keys you can exchange\nthe keys for access tokens.\nSee more here: http://developers.facebook.com/docs/authentication/fb_sig/\n\n==== JavaScript SDK\n\n  fb_auth = FbGraph::Auth.new(YOUR_APP_ID, YOUR_APPLICATION_SECRET)\n  fb_auth.client # =\u003e Rack::OAuth2::Client\n\n  # get Facebook's auth cookie in advance using their JS SDK\n  fb_auth.from_cookie(cookies)\n  fb_auth.access_token # =\u003e Rack::OAuth2::AccessToken\n  fb_auth.user         # =\u003e FbGraph::User (only basic attributes)\n  fb_auth.user.fetch   # =\u003e fetch more details\n\n==== Normal OAuth2 Flow\n\n  # setup client\n  client = fb_auth.client\n  client.redirect_uri = \"http://your.client.com/facebook/callback\"\n\n  # redirect user to facebook\n  redirect_to client.authorization_uri(\n    :scope =\u003e [:email, :read_stream, :offline_access]\n  )\n\n  # in callback\n  client.authorization_code = params[:code]\n  access_token = client.access_token! :client_auth_body # =\u003e Rack::OAuth2::AccessToken\n  FbGraph::User.me(access_token).fetch # =\u003e FbGraph::User\n\n==== Extend Access Token Lifetime\n\n  # setup client\n  fb_auth = FbGraph::Auth.new(YOUR_APP_ID, YOUR_APPLICATION_SECRET)\n  fb_auth.exchange_token! 'short-life-access-token'\n  fb_auth.access_token # =\u003e Rack::OAuth2::AccessToken\n\n\n=== Analytics\n\n  app = FbGraph::Application.new(YOUR_APP_ID, :secret =\u003e YOUR_APPLICATION_SECRET)\n  app.insights # =\u003e Array of FbGraph::Insight\n\n=== Test User\n\nNot tested well yet.\nSample is here.\nhttps://gist.github.com/752974\n\n=== FQL\n\nNot tested well yet.\nSample is here.\nhttps://gist.github.com/752914\n\n=== More Examples?\n\nSee GitHub wiki for more examples.\nhttps://github.com/nov/fb_graph/wiki\n\n== Note on Patches/Pull Requests\n\n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it. This is important so I don't break it in a\n  future version unintentionally.\n* Commit, do not mess with rakefile, version, or history.\n  (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)\n* Send me a pull request. Bonus points for topic branches.\n\n== Copyright\n\nCopyright (c) 2010 nov matake. See LICENSE for details.\n","funding_links":["https://github.com/sponsors/nov"],"categories":["Ruby","Third-party APIs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnov%2Ffb_graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnov%2Ffb_graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnov%2Ffb_graph/lists"}