Project

invity

0.0
No commit activity in last 3 years
No release in over 3 years
Send message to facebook inbox through your rails app.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Invity

Send messages to Facebook Inbox with your rails app.

demo -- demo source

Installation

Add this line to your application's Gemfile:

gem 'invity'

And then execute:

$ bundle

Or install it yourself as:

$ gem install invity

Usage

Requirements:

  1. xmpp_login ( facebook permissions )
  2. ENV['FACEBOOK_APP_ID']
  3. ENV['FACEBOOK_APP_SECRET']

eg:

using omniauth-facebook

In config/initializer/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, ENV['FACEBOOK_APP_ID'],  ENV['FACEBOOK_APP_SECRET'], scope: "email, xmpp_login"
end

Controller

@invitation = Invity::Facebook::API.new( access_token )

@friends = @invitation.friends
or
@friends = @invitation.friends_with_pics
or
@friends = @invitation.friend_ids

Send Message

  • access_token == facebook access_token from omniauth-facebook
  • sender == user uid from omniauth-facebook
  • recievers == Array of friends ids
  • invitation == should be string
  • body == should be string eg: "#{Time.now}"

Invity::Facebook::Message.new(
  access_token: access_token,
  sender: uid,
  recievers: friends,
  subject: 'Invitation',
  body: "You have been invited to join http://www.example.com"
).deliver

Available methods:

deliver                  == deliver to each passed recievers
deliver(:delayed)        == support delayed_job gem - send as background task
deliver(:all)            == deliver to all friends regardless of passed recievers
deliver(:all_delayed)    == deliver to all with delayed_job gem

delayed_job gem needed for these methods:

deliver(:delayed)
deliver(:all_delayed) 

demo -- demo source