Skip to content

Instantly share code, notes, and snippets.

@GOROman
Created January 24, 2015 14:37
Show Gist options
  • Save GOROman/6c9cec40b04a205e5ebb to your computer and use it in GitHub Desktop.
Save GOROman/6c9cec40b04a205e5ebb to your computer and use it in GitHub Desktop.
Google Glass へ好きなメッセージ通知する (Mirror API使用)
#!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
@GOROman
Copy link
Author

GOROman commented Jan 24, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment