Shorten Method

bitlyDotNET

[This is preliminary documentation and is subject to change.]

Encodes a long URL as a shorter one and returns it.

Namespace:  bitlyDotNET.Interfaces
Assembly:  bit.ly.NET (in bit.ly.NET.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#
eStatusCode Shorten(
	string url,
	out string shortened
)

Parameters

url
Type: System..::.String
A long URL to shorten
shortened
Type: System..::.String %
Contains a long URL if successful, nullNothingnullptra null reference (Nothing in Visual Basic) otherwise.

Return Value

The status code of the request

Remarks

The parameter url shouldn't be URL-escaped.

This method uses XML to parse the response from bit.ly. and LINQ to XML's loading functionality is built upon XmlReader. Therefore, you might catch any exceptions that are thrown by the XmlReader.Create overload methods and the XmlReader methods that read and parse the document.

If you receive a System.Net.WebPermission error, you might want to add the following line in your web.config file:

CopyC#
<system.web><trust level="Medium" originUrl="https?://api\.bit\.ly/.+" /></system.web>

Exceptions

Exception Condition
System..::.ArgumentNullException url is nullNothingnullptra null reference (Nothing in Visual Basic).

See Also