Repository URL to install this package:
Version:
0.11.1 ▾
|
lib |
LICENSE.txt |
README.md |
Rakefile |
action_sprout-facebook.gemspec |
The ActionSprout Facebook Gem! The gem is currently developed and tested against Graph API v9.0, but should work as expected for any version v3.3 or higher.
Make sure you have our Gemfury source added to your Gemfile. (Get this by logging into Gemfury and looking at our repos)
Add this line to your application's Gemfile:
gem 'action_sprout-facebook'
And then execute:
$ bundle
ActionSprout::Facebook::API
This is the main entry point for making requests to Facebook's Graph API.
Basic Usage:
api = ActionSprout::Facebook::API.new access_token: "your_access_token" api.get "<object_id>/path", query: { fields: '...', limit: 42, since: 9999999, until: 9999999 }
ActionSprout::Facebook::Services::GetPublicPostData
This is a method object for getting public post data and stats.
It returns an instance of ActionSprout::Facebook::PublicPostData
.
Basic Usage:
api = ActionSprout::Facebook::API.new access_token: "your_access_token" post_data = ActionSprout::Facebook::Services::GetPublicPostData.call facebook_page_id: "<FB_PAGE_ID>", api: api post_data.posts # => an Array of the posts: # [ # { # "facebook_post_id" => String, # "created_time" => Integer (unix timestamp), # "updated_time" => Integer (unix timestamp), # "message" => post["message"], # "title" => String, # "description" => String, # "caption" => String, # "type" => String, # "link" => String, # "picture" => String, # "reaction_count" => Integer, # "comment_count" => Integer, # "share_count" => Integer, # "engagement_count" => Integer, # }, ... # ] post_data.metrics # => a Hash of the page's metrics # { # "posts_per_day" => Float, # "engagement" => { # "arithmetic" => Float, # "geometric" => Float, # }, # "comments" => { # "arithmetic" => Float, # "geometric" => Float, # }, # "reactions" => { # "arithmetic" => Float, # "geometric" => Float, # }, # "shares" => { # "arithmetic" => Float, # "geometric" => Float, # }, # }
To see what each post Hash contains see ParsePublicPost.rb
Optional arguments: This class takes an optional since
and until
to control the time frame of posts. These are only for testing purposes. In reality you cannot get a historical set of public posts data that is consistent because the post metrics change over time.
ActionSprout::Facebook::Page
This object is for getting a Page's attributes.
api = ActionSprout::Facebook::API.new access_token: "your_access_token" my_page = ActionSprout::Facebook::Page.new "page_id", api: api, fields: 'id,name,fan_count,...' puts my_page.data
ActionSprout::Facebook::PagePosts
This object is for getting a Page's posts for a given time range (defaults to the last 2 weeks).
api = ActionSprout::Facebook::API.new access_token: "your_access_token" posts = PagePosts.new "<page_id>", api: api, since: Time.current-1.week, until: Time.current, fields: 'id,message,type,...', limit: 50 # The :limit will determine your pagination size.
ActionSprout::Facebook::Page
Coming Soon...
After checking out the repo, run bin/setup
to install dependencies.
Then, run bundle exec rspec
to run the tests. You can run bundle exec guard
to run
them in real time.
You can also run bin/console
for an interactive prompt that will allow you to experiment with the gem.
When Submitting a pull request to update the gem - make sure to update the gem version in lib/action_sprout/facebook/version.rb
.