A simple ruby script to send MSDN toast notification for windows phones:
require 'uri'
require 'net/http'
u = URI.parse('your-device-url')
req = Net::HTTP::Post.new(u.path)
req_xml = '<?xml version="1.0" encoding="utf-8"?>'
req_xml << '<wp:Notification xmlns:wp="WPNotification">'
req_xml << '<wp:Toast>'
req_xml << '<wp:Text1>Test title</wp:Text1>'
req_xml << "<wp:Text2>My First notification</wp:Text2>"
req_xml << "<wp:Param>/Page1.xaml?id=123</wp:Param>"
req_xml << '</wp:Toast>'
req_xml << '</wp:Notification>'
req.content_type = 'text/xml'
req['X-WindowsPhone-Target'] = 'toast'
req['X-NotificationClass'] = '2'
req.body = req_xml
resp = Net::HTTP.start(u.host, u.port) do |http|
http.request(req)
end
require 'uri'
require 'net/http'
u = URI.parse('your-device-url')
req = Net::HTTP::Post.new(u.path)
req_xml = '<?xml version="1.0" encoding="utf-8"?>'
req_xml << '<wp:Notification xmlns:wp="WPNotification">'
req_xml << '<wp:Toast>'
req_xml << '<wp:Text1>Test title</wp:Text1>'
req_xml << "<wp:Text2>My First notification</wp:Text2>"
req_xml << "<wp:Param>/Page1.xaml?id=123</wp:Param>"
req_xml << '</wp:Toast>'
req_xml << '</wp:Notification>'
req.content_type = 'text/xml'
req['X-WindowsPhone-Target'] = 'toast'
req['X-NotificationClass'] = '2'
req.body = req_xml
resp = Net::HTTP.start(u.host, u.port) do |http|
http.request(req)
end
No comments:
Post a Comment