Dare Obasanjo's weblog
"You can buy cars but you can't buy respect in the hood" - Curtis Jackson
Navigation for Cuz I'm Outside of the Club You Think I'm a Punk? - Dare Obasanjo's weblog
Content
Sidebar
Footer
September 5, 2003
@ 12:58 AM
Comments [0]
Cuz I'm Outside of the Club You Think I'm a Punk?
using System;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Security.Cryptography;
using System.Text;
using System.Net;
using System.IO;
using System.Threading;
using System.Diagnostics;
public class MsDownload{
public static void Main(string[] args){
try{
XslTransform transform = new XslTransform();
transform.Load(new XmlTextReader( new StringReader(stylesheet)));
while(true){
string soapRequest = BuildSoapRequest();
HttpWebResponse response = SendRequest(soapRequest);
string soapResponse = GetResponseString(response);
XPathDocument doc = new XPathDocument(new XmlTextReader(new StringReader(soapResponse)));
transform.Transform(doc, null, new XmlTextWriter(new StreamWriter("MsftTop10Downloads.rss")));
Console.WriteLine("DONE");
Thread.Sleep(30 * 60 * 1000); /* sleep for 30 minutes */
}
}catch(WebException e){
if(e.Response != null)
Console.WriteLine(GetResponseString((HttpWebResponse) e.Response));
else
Console.WriteLine(e);
}catch(Exception ex){
Console.WriteLine(ex);
}
}
public static HttpWebResponse SendRequest(string soapmessage){
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(endpoint);
request.Timeout = 1 * 60 * 1000;
request.Method = "POST";
request.ContentType = "text/xml";
request.Headers.Add("SOAPAction", "http://www.microsoft.com/GetTopDownloads");
request.ContentLength = soapmessage.Length;
StreamWriter myWriter = null;
try{
myWriter = new StreamWriter(request.GetRequestStream());
myWriter.Write(soapmessage);
} catch(Exception e){
throw new WebException(e.Message, e);
}finally{
if(myWriter != null){
myWriter.Close();
}
}
return (HttpWebResponse) request.GetResponse();
}
public static string GetResponseString(HttpWebResponse response){
StringBuilder sb = new StringBuilder();
StringWriter writeStream = null;
StreamReader readStream = null;
writeStream = new StringWriter(sb);
//Retrieve input stream from response and specify encoding
Stream receiveStream = response.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a higher level stream reader with the required encoding format.
readStream = new StreamReader( receiveStream, encode );
Char[] read = new Char[256];
int count = readStream.Read( read, 0, 256 );
while (count > 0) {
// Dumps the 256 characters on a string and displays the string to the console.
writeStream.Write(read, 0, count);
count = readStream.Read(read, 0, 256);
}
return sb.ToString();
}
public static string BuildSoapRequest(){
/* build Nonce */
string data = "Carnage4Life";
SHA1 sha = new SHA1CryptoServiceProvider();
byte[] temp = sha.ComputeHash(Encoding.Default.GetBytes(data));
string nonce = Convert.ToBase64String(temp);
/* Build Expired and Created */
DateTime created = DateTime.Now;
DateTime expired = created + new TimeSpan(0, 0, 180);
/* build Digest */
sha = new SHA1CryptoServiceProvider();
temp = sha.ComputeHash(Encoding.Default.GetBytes( Encoding.Default.GetString(temp) + created.ToUniversalTime().ToString("s")+ "Z" + pin));
string digest = Convert.ToBase64String(temp);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
sw.Write(request, tokenID, digest + "\n", nonce + "\n", created.ToUniversalTime().ToString("s") + "Z", expired.ToUniversalTime().ToString("s") + "Z");
sw.Close();
return sb.ToString();
}
public const string tokenID = "0RBzMjyHym5wBwxvnBXmTYbL6XgaQfAR";
public const string pin = "GUnit!";
public const string endpoint = "http://ws.microsoft.com/mscomservice/mscom.asmx";
public static string request = @"<soap:Envelope
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:wsu='http://schemas.xmlsoap.org/ws/2002/07/utility'
xmlns:wsse='http://schemas.xmlsoap.org/ws/2002/07/secext'>
<soap:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>{0}</wsse:Username>
<wsse:Password Type='wsse:PasswordDigest'>{1}</wsse:Password>
<wsse:Nonce>{2}</wsse:Nonce>
<wsu:Created>{3}</wsu:Created>
<wsu:Expires>{4}</wsu:Expires>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<GetTopDownloads xmlns='http://www.microsoft.com'>
<topType>Popular</topType>
<topN>10</topN>
<cultureID>en-US</cultureID>
</GetTopDownloads>
</soap:Body>
</soap:Envelope>";
public static string stylesheet = @"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'
xmlns:b0rg='http://www.microsoft.com' exclude-result-prefixes='b0rg'>
<xsl:output method='xml' indent='yes' />
<xsl:template match='/'>
<rss><channel>
<title>Microsoft Top 10 Downloads (en-US)</title>
<link>http://msdn.microsoft.com/webservices/building/livewebservices/mscom services/default.aspx</link>
<description>The Microsoft Top 10 Downloads XML Web Service exposed as an RSS feed</description>
<language>en</language>
<xsl:for-each select='//b0rg:DownloadSummary'>
<item>
<link><xsl:value-of select='b0rg:DetailsUrl' /></link>
<title><xsl:value-of select='b0rg:ShortName' /></title>
<description><xsl:value-of select='b0rg:ShortDescription' /></description>
</item>
</xsl:for-each>
</channel></rss>
</xsl:template>
</xsl:stylesheet>";
}
Tweet
Categories:
Tracked by:
http://www.25hoursaday.com/weblog/PermaLink.aspx?guid=6c995877-94ac-44a0-83c3-6f...
[Pingback]
http://silauma.info/virginia/sitemap1.html
[Pingback]
http://yftbsy1.net/games/sitemap1.html
[Pingback]
http://yftbsy1.net/nascar/sitemap1.html
[Pingback]
http://ptmy0sx.net/florida/sitemap1.html
[Pingback]
http://mc4bmvg.net/05/index.html
[Pingback]
http://bombaylogger.web.aplus.net/00/index.html
[Pingback]
http://tkru7ln.net/sitemap1.html
[Pingback]
http://restablog.dreamhosters.com/toys/sitemap1.html
[Pingback]
http://host239.hostmonster.com/~blogford/sitemap2.html
[Pingback]
http://gator413.hostgator.com/~digital/wedding/sitemap1.html
[Pingback]
http://fskh6vo.net/sitemap1.html
[Pingback]
http://tyzzlpp.net/sublets/sitemap1.html
[Pingback]
http://ujprjlw.net/post/sitemap1.html
[Pingback]
http://box432.bluehost.com/~zbloginf/sitemap1.html
[Pingback]
http://gator442.hostgator.com/~hockteam/university/sitemap1.html
[Pingback]
« Ride or Die
|
Home
|
Always Ask Questions »
Comments are closed.
RSS/Subscribe
Archives
All dates
All Posts
Search
Latest Posts
Culture Eats Strategy for Breakfast
Some Thoughts on Paul Graham’s Essay on Income Inequality
How Facebook Knows Who You’re Talking to on Tinder and OKCupid
Fabric: Why Developers Can Trust Twitter Won’t Screw Them This Time
5 Account Security Features Every Online Service Should Implement But Doesn't
Facebook’s Newsfeed Experiment: Most people have grabbed the wrong end of the stick
Change is bad unless it’s great: Lessons from user revolts against Foursquare’s Swarm and the new Skype for iPhone
Facebook’s App Links: The Good, the Bad and the Ugly
The mobile web vs apps is another front on the battle between open and closed systems
How Facebook Knows What You Looked at on Amazon
Categories
Cloud Computing (5)
Comics (1)
Competitors/Web Companies (161)
Current Affairs (31)
Das Blog (3)
dasBlog (1)
Life in the B0rg Cube (197)
Mindless Link Propagation (185)
Movie Review (13)
MSN (127)
Music (20)
Office Live (8)
Personal (54)
Platforms (59)
Programming (58)
Ramblings (145)
Rants (7)
RSS Bandit (215)
Seattle Startup Shoutout (4)
Social Software (185)
Startup Shoutout (4)
Syndication Technology (108)
Technology (169)
Trip Report (63)
Video Games (6)
Web Development (198)
Windows Live (227)
XML (203)
XML Web Services (114)
Archives
January, 2016 (2)
October, 2015 (1)
October, 2014 (1)
September, 2014 (1)
July, 2014 (1)
June, 2014 (1)
May, 2014 (1)
April, 2014 (1)
February, 2014 (1)
January, 2014 (1)
December, 2013 (1)
November, 2013 (2)
July, 2013 (1)
March, 2013 (1)
November, 2012 (2)
September, 2012 (2)
July, 2012 (3)
June, 2012 (1)
April, 2012 (1)
February, 2012 (1)
January, 2012 (1)
November, 2011 (1)
September, 2011 (3)
July, 2011 (2)
June, 2011 (1)
April, 2011 (1)
March, 2011 (1)
January, 2011 (2)
November, 2010 (2)
October, 2010 (2)
August, 2010 (3)
July, 2010 (3)
June, 2010 (3)
April, 2010 (6)
March, 2010 (3)
February, 2010 (5)
January, 2010 (4)
December, 2009 (2)
November, 2009 (8)
October, 2009 (1)
September, 2009 (3)
August, 2009 (4)
June, 2009 (1)
May, 2009 (12)
April, 2009 (5)
March, 2009 (17)
February, 2009 (11)
January, 2009 (20)
December, 2008 (12)
November, 2008 (12)
October, 2008 (22)
September, 2008 (12)
August, 2008 (15)
July, 2008 (18)
June, 2008 (19)
May, 2008 (12)
March, 2008 (2)
February, 2008 (27)
January, 2008 (20)
December, 2007 (26)
November, 2007 (26)
October, 2007 (29)
September, 2007 (16)
August, 2007 (34)
July, 2007 (26)
June, 2007 (33)
May, 2007 (37)
April, 2007 (14)
March, 2007 (32)
February, 2007 (35)
January, 2007 (29)
December, 2006 (29)
November, 2006 (47)
October, 2006 (26)
September, 2006 (46)
August, 2006 (40)
July, 2006 (38)
June, 2006 (48)
May, 2006 (33)
April, 2006 (39)
March, 2006 (38)
February, 2006 (42)
January, 2006 (42)
December, 2005 (43)
November, 2005 (40)
October, 2005 (48)
September, 2005 (45)
August, 2005 (40)
July, 2005 (31)
June, 2005 (36)
May, 2005 (38)
April, 2005 (31)
March, 2005 (39)
February, 2005 (22)
January, 2005 (25)
December, 2004 (32)
November, 2004 (27)
October, 2004 (24)
September, 2004 (26)
August, 2004 (23)
July, 2004 (25)
June, 2004 (29)
May, 2004 (39)
April, 2004 (37)
March, 2004 (41)
February, 2004 (51)
January, 2004 (54)
December, 2003 (42)
November, 2003 (40)
October, 2003 (41)
September, 2003 (8)
August, 2003 (11)
July, 2003 (9)
June, 2003 (14)
May, 2003 (12)
April, 2003 (12)
March, 2003 (13)
February, 2003 (13)
January, 2003 (13)
December, 2002 (12)
November, 2002 (8)
October, 2002 (6)
September, 2002 (5)
August, 2002 (6)
July, 2002 (6)
June, 2002 (4)
May, 2002 (8)
April, 2002 (3)
March, 2002 (1)
February, 2002 (1)
January, 2002 (4)
November, 2001 (4)
October, 2001 (3)
September, 2001 (3)
August, 2001 (1)
July, 2001 (1)
May, 2001 (0)
April, 2001 (2)
March, 2001 (2)
BlogRoll
Alexander Groß
Anthony Bouch
Ben Scheirman
Clemens Vasters
Erv Walter
Gray's Matter
Harry Pierson
James Snape
John Forsythe
Joshua Flanagan
Kris van der Mast
Mark Michaelis
Michael Earls
Omar Shahine
Paulb Vanbrenk
Scott Hanselman
Stephen Forte
Steven Rockarts
Tom Mertens
Tom Watts
Tony Bunce
Vasanth Dharmaraj
Categories
Cloud Computing
Comics
Competitors/Web Companies
Current Affairs
Das Blog
dasBlog
Life in the B0rg Cube
Mindless Link Propagation
Movie Review
MSN
Music
Office Live
Personal
Platforms
Programming
Ramblings
Rants
RSS Bandit
Seattle Startup Shoutout
Social Software
Startup Shoutout
Syndication Technology
Technology
Trip Report
Video Games
Web Development
Windows Live
XML
XML Web Services
Contact the Author
Themes
Pick a theme:
BlogXP
business
calmBlue
Candid Blue
dasBlog
dasblogger
dasblueblog
dasEmerald
DirectionalRedux
Discreet Blog Blue
Elegante
essence
Just Html
MadsSimple
Mobile
Mono
Movable Radio Blue
Movable Radio Heat
nautica022
orangeCream
Portal
Project84
Project84Grass
Slate
Sound Waves
Tricoleur
useit.com
Voidclass2
Admin
Sign In