Class: Aboie::Client
- Inherits:
-
Object
- Object
- Aboie::Client
- Defined in:
- lib/aboie/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#initialize(api_key = nil) ⇒ Client
constructor
A new instance of Client.
- #send_text(who, msg) ⇒ Object
Constructor Details
#initialize(api_key = nil) ⇒ Client
Returns a new instance of Client.
4 5 6 |
# File 'lib/aboie/client.rb', line 4 def initialize(api_key=nil) self.api_key = api_key || Aboie.configuration.api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/aboie/client.rb', line 3 def api_key @api_key end |
Instance Method Details
#send_text(who, msg) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aboie/client.rb', line 8 def send_text(who, msg) payload = { recipient: {id: who}, message: {text: msg} } begin RestClient.post("https://graph.facebook.com/v2.6/me/messages?access_token=#{self.api_key}", payload.to_json, {accept: :json, content_type: :json} ) rescue StandardError => e puts e.response.inspect puts e.response.body raise e end end |