Skip to content

Instantly share code, notes, and snippets.

@cnosuke
Created October 23, 2012 09:53
Show Gist options
  • Save cnosuke/3937954 to your computer and use it in GitHub Desktop.
Save cnosuke/3937954 to your computer and use it in GitHub Desktop.
iPhoneに通知出したいときに使う用のアレをkayacさんありがとう的なアレ
# coding: utf-8
#
# Copyright (C) 2012 Shinnosuke TAKEDA All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# http://www.gnu.org/licenses/gpl.txt
require 'net/http'
require 'json'
IM_KAYAC_API = "http://im.kayac.com/api/post/#{YOUR_USER_ACCOUNT}"
class Kayac
def self.post(post_data = self.postdata)
result = {}
uri = URI.parse(IM_KAYAC_API)
http = Net::HTTP.new(uri.host, uri.port)
http.start do |http|
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(post_data)
http.request(request) do |res|
res.read_body do |body|
result = JSON.parse(body)
end
end
end
return result
end
def self.postdata
{
:message => "Hellow Kayac World!",
:handler => "http://google.com/",
#:password : "hoge",
#:sig : "sigsig"
}
end
end
p Kayac.post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment