X hits on this document

93 views

0 shares

0 downloads

0 comments

17 / 28

Bit.ly Restful Example - simple

protected void bGetInfo_Click(object sender, EventArgs e)

 {

   string apiKey = "&apiKey=APIkey";

   string loginKey="&login=rusername";

     //encode the string

       string shortUrl =shorturl"&shortUrl= "+ Server.HtmlEncode(txtURL.Text);

// Format for string sent is - http://api.bit.ly/v3/clicks?&shortUrl=http%3A%2F%2Fbit.ly%2FavNcS4&login=login&apiKey=key&format=xml

     // URL must be encoded

       WebRequest req = WebRequest.Create("http://api.bit.ly/v3/clicks?" + shortUrl + apiKey + loginKey);

       WebResponse resp = req.GetResponse();

       Stream stream =resp.GetResponseStream();

       StreamReader sr = new StreamReader(stream);

       String s=sr.ReadToEnd();

       txtInfo.Text=s;

 }

WebRequest

WebResponse

Document info
Document views93
Page views93
Page last viewedWed Jan 18 07:00:33 UTC 2017
Pages28
Paragraphs438
Words1567

Comments