Created
April 5, 2012 05:29
-
-
Save satyatechsavy/2308226 to your computer and use it in GitHub Desktop.
Notification to Windows8
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 'windows8_system' | |
require 'fetch_windows8_access_token' | |
require 'net/http' | |
require 'net/https' | |
class Windows8Notification < Windows8System | |
def self.process(device_uri,message) | |
puts "iha" | |
device_uri = "https://db3.notify.windows.com/?token=AgUAAAADoGlaM0THo74Q%2bJP7MkgBEJzYC7OyTwh59QmECe9MgwfwGSWLsMhkG%2bHF3JI3q3gySjc3keErqcwWYCN9Qwi2z7TdCMnYGb30huMkKrzB54%2fH73vxrYzp36SQScHazJA%3d" | |
#device_uri = CGI.unescape(device_uri) | |
puts device_uri | |
uri = URI.parse(device_uri) | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
puts uri.host | |
puts uri.port | |
puts uri.path | |
data = "<toast><visual version='1' lang='en-US'><binding template='ToastText02'><text id='1'>Heading text</text><text id='2'>Body text that wraps.</text></binding></visual></toast>" | |
windows_access_token = "EgAbAQMAAAAEgAAACoAAXlVPAkijl7lt4m5qCG19d2NwSZAusm3w8Wa8j342JL0mwRUBsoXeUqdb9vAm5gjW7LMfUPC1EvzrCXex7wWR3xQLqS9JyfSsHDppG1gX/BYLWk+RBqPoqLDtSHebOZqRvdmS50xVxwoCEENU9Jb6fFIZOAsHk1RNQTOKGQCXWmOKAFoAigAAAAAAIyoJSG4efU9uHn1P60gEAAwANTAuNTYuMjkuNjYAAAAAAF4AbXMtYXBwOi8vcy0xLTE1LTItMjE5MjI2NjY4MS02NzE5MTgwNTgtMzA2OTc2Njc1OS0zOTQxOTc4MjM3LTM1ODk1NjIwODItMzQ5MDEwNTY0OS0zMjM0ODY1MDExAA==" | |
headers = {"Content-Type" => "text/xml", | |
"Content-Length" => data.length.to_s, | |
"X-WNS-Type" => "wns/toast", | |
"X-WNS-RequestForStatus" => "true", | |
"host" => "cloud.notify.windows.com", | |
"Authorization" => ("Bearer "+ Settings.windows8_access_token + "a")} | |
resp, data = http.post(uri.path, data, headers) | |
puts 'Code = ' + resp.code | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment