-1

I want to make a URL shortener that uses and online URL shortener API.

I want to use this API here -> http:// cut2.tk/api-about.php

So the API code is this:

http://cut2.tk/api.php?url= LONG URL HERE

I want to use an user form with two text boxes and two buttons.

The first button is to short URL and the second to copy the short URL from the second textbox.

The first text box is where I'm going to paste the long URL, and the second textbox is where I'm going to get the short URL after I press the short URL button.

Like this:

Image

How can I make the project or the code?

I'm using Microsoft Excel Developer Visual Basic.

4

1 回答 1

3

这将为您使用 API,这是您最初要求的:

Sub getShortURL()
    Dim objHTTP, URL
    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    URL = "http://cut2.tk/api.php?url=" & Me.LongUrl.Value
    objHTTP.Open "POST", URL, False
    objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
    objHTTP.send ("")
    Me.ShortURL.Value = objHTTP.responseText
End Sub
于 2012-12-16T17:44:33.470 回答