Method: Instagram::Client::Subscriptions#process_subscription
- Defined in:
- lib/instagram-fixed/client/subscriptions.rb
#process_subscription(json, &block) ⇒ nil
Process a subscription notification JSON payload
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/instagram-fixed/client/subscriptions.rb', line 123 def process_subscription(json, ={}, &block) raise ArgumentError, "callbacks block expected" unless block_given? if [:signature] if !client_secret raise ArgumentError, "client_secret must be set during configure" end digest = OpenSSL::Digest::Digest.new('sha1') verify_signature = OpenSSL::HMAC.hexdigest(digest, client_secret, json) if [:signature] != verify_signature raise Instagram::InvalidSignature, "invalid X-Hub-Signature does not match verify signature against client_secret" end end payload = MultiJson.decode(json) @changes = Hash.new { |h,k| h[k] = [] } for change in payload @changes[change['object']] << change end block.call(self) end |