BLOGを作ってるわけですが、なんとかエントリを書くところまでは動くようになった。とりあえず、このJUGEM宛てにPingを送ってみたら、最初は文字化けしちゃったりしたけど、エンコードの指定をしたらちゃんと表示された。
// pingurlsには改行で区切られたURLのリストが格納されている。
string[] urls = pingurls.Split('¥n');
string entryTitle = "Entry Title";
int entryid = 1;
string blogname = "Sample";
System.Text.Encoding enc = System.Text.Encoding.GetEncoding("UTF-8");
// POSTするデータ
string postData = "title=" + entryTitle +
"&url=" + "http://localhost/shirokuma/note.aspx?id=" + entryid.ToString() +
"&blog_name=" + blogname;
byte[] postDataBytes = System.Text.Encoding.UTF8.GetBytes(postData);
for(int i=0; i<urls.Length; i++ ) {
WebRequest req = HttpWebRequest.Create( urls[i] );
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = postDataBytes.Length;
System.IO.Stream reqStream = req.GetRequestStream();
reqStream.Write(postDataBytes, 0, postDataBytes.Length);
reqStream.Close();
WebResponse res = req.GetResponse();
System.IO.Stream resStream = res.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, enc);
string pingres = sr.ReadToEnd();
sr.Close();
}


コメント
propecia pills
ASP.NETでTrackback送信