how to send trackback and pingback using c# script

Posted by anirudha on Geeks with Blogs See other posts from Geeks with Blogs or by anirudha
Published on Wed, 08 Dec 2010 11:01:14 GMT Indexed on 2010/12/08 18:00 UTC
Read the original article Hit count: 428

Filed under:

This is a very interesting topic because if you want to search about them. you find much useless stuff even you use c# as prefix.

1. how trackback works ?

Every blog who have support to trackback that in their every post they have some text comment like

<rdf:/rdf></rdf:rdf>  inside this tag the attribute “trackback:ping” have a url where we can send trackback.

2. you need some information about your blog to post where you want to trackback like

1. URL where you want to send the trackback

2. your post title [may be page title]

3. your post URL [may be page url]

4.  Excerpt : information you want to send.

5. you blogname [may be sitename if you use site not blog]

make the information like querystring just we use in asp.net ex:

title=”pingpost&url=pingurl&excerpt=it’s me&blog=myblog” ;

the information look like asp.net Querystring if you unsure that you can HTMLencode the information who you use in parameters.

you need to be sure that your post have URL of post where you want to send trackback. make  a request to pingurl set the following property

request.Method = “POST”; //because they support only POST

request.ContentLength = param.length // choose the length of parameters we create for sending ping.

request.ContentType = "application/x-www-form-urlencoded"; // required to set.

now when you send the request then server respond you something about your request

check that the request.statuscode is verify that’s work or not

if (response.StatusCode < HttpStatusCode.OK && response.StatusCode >= HttpStatusCode.Ambiguous)

                    throw new Exception(string.Format(response.StatusCode.ToString()));

because you have the response in XML format you can parse the response that’s have Error tag inside them or not.

i put here information not code the reason is that “i see some other blog from a week on the topic but i found that they[blogger] post code not the method and all their code are useless and not worked”. because i thing to be more declarative i post here the definition not code.

© Geeks with Blogs or respective owner