Class: Twilio::Utils
- Inherits:
-
Object
- Object
- Twilio::Utils
- Defined in:
- lib/twiliolib.rb
Overview
Twilio Utility function and Request Validation class
Instance Method Summary collapse
-
#initialize(id, token) ⇒ Object
constructor
initialize a twilio utils abject.
- #validateRequest(signature, url, params = {}) ⇒ Object
Constructor Details
#initialize(id, token) ⇒ Object
initialize a twilio utils abject
373 374 375 376 |
# File 'lib/twiliolib.rb', line 373 def initialize(id, token) @id = id @token = token end |
Instance Method Details
#validateRequest(signature, url, params = {}) ⇒ Object
378 379 380 381 382 383 384 385 386 387 |
# File 'lib/twiliolib.rb', line 378 def validateRequest(signature, url, params = {}) sorted_post_params = params.sort data = url sorted_post_params.each do |pkey| data = data + pkey[0]+pkey[1] end digest = OpenSSL::Digest::Digest.new('sha1') expected = Base64.encode64(OpenSSL::HMAC.digest(digest, @token, data)).strip return expected == signature end |