Created
January 24, 2015 14:37
-
-
Save GOROman/6c9cec40b04a205e5ebb to your computer and use it in GitHub Desktop.
Google Glass へ好きなメッセージ通知する (Mirror API使用)
This file contains hidden or 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
#!ruby -Ku | |
# Google Glass へメッセージ通知 (Mirror API) | |
# by GOROman | |
require 'net/http' | |
require 'json' | |
# OAuthで得たトークン | |
TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
API = 'https://www.googleapis.com/mirror/v1/timeline' | |
uri = URI.parse(API) | |
# GoogleGlassに通知したいメッセージ | |
json = { | |
text: "おっす", | |
notification: { level: "DEFAULT" } | |
}.to_json | |
req = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json', 'Authorization' => 'OAuth '+TOKEN }) | |
req.body = json | |
https = Net::HTTP.new(uri.host, uri.port) | |
https.use_ssl = true | |
https.start do |h| | |
res = h.request(req) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Google Mirror API Reference
https://developers.google.com/glass/v1/reference/