![]() ![]() If the status is "200", the request was successful and state_text contains the tiny URL. status_code contains the status of the request. Next, it calls the helper method ReadValue() to read the status_code and status_text values from the returned XML data. The GetTinyUrl() then loads the response into an XmlDocument instance. If your application is a web application and/or you are referencing the required libraries, you can eliminate the UrlEncode() and IsSafeUrlCharacter() methods and use the UrlEncode() method that is part of the. NET provides it's own UrlEncode() method however, it is not normally referenced from a WinForms application. To keep the integrity of this request URL, the URL being shortened is URL-encoded using the UrlEncode() method. GetTinyUrl() starts by constructing a request that includes the login information and original URL. ![]() Plug that login information into the private _apiLogin and _apiKey constants, and you should be ready to go. To get this code to work, you'll need to go to bit.ly and register for your own login information. bit.ly requires a login key in order to generate the tiny URL. The TinyUrl class contains a single public method, GetTinyUrl(), which is static and returns the tiny version of the specified URL. The tiny URL is obtained by querying the bit.ly application programming interface (API). This class allows an application to programmatically take a regular URL and produce a tiny URL. One of the more common URL-shortening sites is bit.ly, which was used by Twitter before they created their own URL-shortening site, t.co. Tiny URLs have been made popular by sites like Twitter, which limit the number of characters that can appear in a message. When this URL is requested, the site then uses information embedded in the tiny URL to look up the original URL, and then redirects to that original URL. The smaller URL, or tiny URL, points to the site that generated it. These sites take a regular URL and produce a smaller URL. URL-shortening sites are very common these days. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |