Sending Trackback To A Blog With c#
i am facing a liitle problem. i think
anyone can help me. i am trying to send
trackback to a blog from a c# application.
when i send trackback reply from blog
shows that it gets the trackback. but
nothing is posted in the blog.
here is my piece of code which actully
performing this. i hope someone can
figure out problem what i am doing wrong.
///url=url of the post which sends trackback
//blog name=name of the blog which sends trackback
//tburl=url to which trackback will be send
//title=title of the trackback
//excerpt=comments
void SendTrackBck(string url,string title,string blog_name,string excerpt,string tburl)
{
try
{
string szTrackbackUrl = tbUrl;
HttpWebRequest hwrTrackback = (HttpWebRequest)WebRequest.Create(szTrackbackUrl);
hwrTrackback.Method = "POST";
StringBuilder sbFormData = new StringBuilder ();
sbFormData.AppendFormat("url={0}", HttpUtility.UrlEncode(url));
sbFormData.AppendFormat ("&title={0}", HttpUtility.UrlEncode (title));
sbFormData.AppendFormat ("&blog_name={0}", HttpUtility.UrlEncode (blog_name));
sbFormData.AppendFormat ("&excerpt={0}", HttpUtility.UrlEncode (excerpt));
hwrTrackback.ContentType = "application/x-www-form-urlencoded";
hwrTrackback.KeepAlive = false;
byte [] abFormData = System.Text.Encoding.UTF8.GetBytes (sbFormData.ToString ());
hwrTrackback.ContentLength = abFormData.Length;
Stream strFormData = hwrTrackback.GetRequestStream ();
strFormData.Write (abFormData, 0, abFormData.Length);
strFormData.Close ();
HttpWebResponse hwrResponse = (HttpWebResponse) hwrTrackback.GetResponse ();
Stream stream = hwrResponse.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string read = reader.ReadToEnd();
reader.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show (ex.ToString ());
}
}
thanks
rashed
|