Created
November 13, 2013 13:16
-
-
Save kad1r/7448936 to your computer and use it in GitHub Desktop.
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
// I have ping list like Wordpress, and I'm getting it from db. | |
// string[] listToPing = dtGetPingList.Rows[0]["pinglist"].ToString().Split(','); | |
private void sendPings(string[] listToPing) | |
{ | |
for (int i = 0; i < listToPing.Count; i++) | |
{ | |
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(listToPing[i].ToString()); | |
request.Method = "POST"; | |
request.ContentType = "text/xml"; | |
Stream stream = (Stream)request.GetRequestStream(); | |
using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.UTF8)) | |
{ | |
xml.WriteStartDocument(); | |
xml.WriteStartElement("methodCall"); | |
xml.WriteElementString("methodName", "weblogUpdates.ping"); | |
xml.WriteStartElement("params"); | |
xml.WriteStartElement("param"); | |
xml.WriteElementString("value", sitename); | |
xml.WriteEndElement(); | |
xml.WriteStartElement("param"); | |
xml.WriteElementString("value", siteaddress); | |
xml.WriteEndElement(); | |
xml.WriteEndElement(); | |
xml.WriteEndElement(); | |
xml.Close(); | |
} | |
try | |
{ | |
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | |
{ | |
using (StreamReader sr = new StreamReader(response.GetResponseStream())) | |
{ | |
string result = sr.ReadToEnd(); | |
sr.Close(); | |
} | |
response.Close(); | |
} | |
} | |
catch (Exception ex) | |
{ | |
string error = ex.Message; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment