Last active
December 30, 2015 00:19
-
-
Save tanatana/7749176 to your computer and use it in GitHub Desktop.
im.kayac.com を Ruby からつかう
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
require 'net/http' | |
require 'uri' | |
IM_KAYAC_SECRET = "YOUR SECRET KEY" | |
IM_KAYAC_USER_ID = "YOUR USER ID" | |
def sendMessage(msg) | |
sha1builder = OpenSSL::Digest.new('sha1') | |
Net::HTTP.post_form(URI.parse("http://im.kayac.com/api/post/#{IM_KAYAC_USER_ID}"), | |
{'message'=>msg, 'sig'=>sha1builder.hexdigest(""+msg+IM_KAYAC_SECRET)}) | |
end | |
sendMessage('Hello!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment