# encoding: ascii
# api: powershell
# title: Get-ShortURL
# description: Uses the Bit.ly api to create a short url. Requires a login and api key from http://bit.ly
# version: 2.0.1
# type: function
# license: CC0
# function: Get-ShortURL
# x-poshcode-id: 1407
# x-archived: 2009-10-26T15:25:25
#
#
Function Get-ShortURL {
Param($longURL, $login, $apiKey)
$url = "http://api.bit.ly/shorten?version=2.0.1&format=xml&longUrl=$longURL&login=$login&apiKey=$apikey"
$request = [net.webrequest]::Create($url)
$responseStream = new-object System.IO.StreamReader($request.GetResponse().GetResponseStream())
$response = $responseStream.ReadToEnd()
$responseStream.Close()
$result = [xml]$response
Write-Output $result.bitly.results.nodeKeyVal.shortUrl
}