Baidu Short URLサービスはじめに:http://www.baidu.com/search/dwz.html
通常、PHPで実装されているため、実装にASPを使用する方法は、以下に書かれた一時的なデモを参照してください。
-------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- ------- ------------------------------------------------------------- ----------------
<%@言語= vbscript codepage = 65001%>
<%
Response.charset = utf-8
session.codepage = 65001
session.timeout = 1440
server.scripttimeout = 99999
'リモート取得
function posttttpage(posturl、postset、postdata、postreferr)
If strust(lcase(posturl)、http://)= 0 then
posthttppage = $ null $:exit関数
ifを終了します
エラーの再開時に次に再開します
dim postthtp
'set posthttp = server.createObject(msxml2.xmlhttp)
'set posthttp = server.createObject(microsoft.xmlhttp)
set posthttp = server.createObject(msxml2.serverxmlhttp)
'set posthttp = server.createObject(msxml2.serverxmlhttp.3.0)
'set posthttp = server.createObject(msxml2.serverxmlhttp.4.0)
posthttp.settimeouts 10000、10000、15000、15000
Posttttp.Open Post、posturl、false
posthttp.setrequstheaderコンテンツレングス、len(ポストダタ)
posthttp.setRequestheaderコンテンツタイプ、Application/X-WWW-Form-urlencoded
posthttp.setRequestheader参照、postreferr
posthttp.send postdata
posthttp.reamstate <> 4およびposthttp.status <> 200 thenの場合
set posthttp = Nothing
posthttppage = $ null $:exit関数
ifを終了します
posthttppage = bytestobstr(posthttp.responsebody、postset)
set posthttp = Nothing
err.number <> 0の場合、err.clear
posppage =またはisnull(posthttppage)の場合、posthttppage = $ null $
エンド関数
関数bytestobstr(body、cset)
DIM OBJSTREAM
objstream = server.createobject(adodb.stream)を設定します
objstream.type = 1
objstream.mode = 3
objstream.open
objstream.write?
objstream.position = 0
objstream.type = 2
objstream.charset = cset
bytestobstr = objstream.readtext
objstream.close
objstream = Nothingを設定します
エンド関数
関数urlencoding(datastr)
Dim Strreturn、SI、Thiskr、InnerCode、Hight8、Low8
strreturn =
si = 1の場合(datastr)
thischr = mid(datastr、si、1)
if abs(asc(thiscr))<&hff then
strreturn = strreturn&thiskr
それ以外
innercode = asc(thischr)
InnerCode <0の場合
innercode = innercode +&h10000
ifを終了します
hight8 =(innercode and&hff00)/&hff
low8 = innercode and&hff
strreturn = strreturn&%&hex(hight8)&%&hex(low8)
ifを終了します
次
urlencoding = streturn
エンド関数
dim test_url:test_url = url = http://www.vevb.com/develop/asp/v74697
dim p_data:p_data = urlencoding(test_url)
dim v_date:v_date = posthtpppage(http://www.dwz.cn/create.php、utf-8、p_data、http://www.dwz.cn)
respons.write:&v_date&<br/>によって取得されたJSONデータ
dim v_json:set v_json = toobject(v_date)
Response.Write Original Webサイト:&v_json.Longurl&<br/>
Response.write short url:&v_json.tinyurl&<br/>
v_json =何も設定しません
%>
<スクリプト言語= jscript runat = server>
function toobject(json){
eval(var o = + json);
oを返します。
}
</script>
-------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- --------------------------------------------------------- -------------------------------------------------------------- --------
上記のコードの結果は次のとおりです。
取得したJSONデータ:{longurl:http:////www.vevb.com//develop//asp/v74697、status:0、tinyurl:http:///www.dwz.cn/2gggul}
元のウェブサイト:http://www.vevb.com/develop/asp/v74697
取得した短いURL:http://www.dwz.cn/2ggul
上記は、単に操作原則を書くことです。