축약 URL, 단축 URL 생성 ASP function
제목 : 축약 URL, 단축 URL 생성 ASP function
소스 :
Function getShortUrlBitly(ByVal longUrl, ByRef resultCode, ByRef resultTxt)
Dim Rs
Dim sql
Dim objRoot
Dim requestUrl : requestUrl = "http://api.bit.ly/v3/shorten"
Dim username, apiKey
Dim params
Dim result : result = longUrl
resultCode = "900"
resultTxt = ""
username = "" : apiKey = "" '//값을 넣어야함.
If username <> "" And apiKey <> "" Then
Set objRoot = xmlDoc(xmlHttpSend("GET", _
Null, _
requestUrl, _
"login="& username &"&apiKey="& apiKey &"&longUrl="& Server.URLEncode(longUrl) &"&format=xml" _
))
If Not objRoot Is Nothing Then
With objRoot
resultCode = .selectSingleNode("status_code").Text
resultTxt = .selectSingleNode("status_txt").Text
If resultCode = "200" Then
result = .selectSingleNode("data").selectSingleNode("url").Text
Else
resultCode = statusCode
resultTxt = statusTxt
End If
End With
End If
Set objRoot = Nothing
End If
getShortUrlBitly = result
End Function
내용 :
예제 소스 파일 :
출처 :