测试短网址:http://dwz.cn/
生成短网址
c
h
=
c
u
r
l
i
n
i
t
(
)
;
c
u
r
l
s
e
t
o
p
t
(
ch=curl_init(); curl_setopt(
ch=curlinit();curlsetopt(ch,CURLOPT_URL,“http://dwz.cn/create.php”);
curl_setopt(
c
h
,
C
U
R
L
O
P
T
P
O
S
T
,
t
r
u
e
)
;
c
u
r
l
s
e
t
o
p
t
(
ch,CURLOPT_POST,true); curl_setopt(
ch,CURLOPTPOST,true);curlsetopt(ch,CURLOPT_RETURNTRANSFER,true);
d
a
t
a
=
a
r
r
a
y
(
′
u
r
l
′
=
>
′
h
t
t
p
:
/
/
w
w
w
.
b
a
i
d
u
.
c
o
m
/
′
)
;
c
u
r
l
s
e
t
o
p
t
(
data=array('url'=>'http://www.baidu.com/'); curl_setopt(
data=array(′url′=>′http://www.baidu.com/′);curlsetopt(ch,CURLOPT_POSTFIELDS,$data);
s
t
r
R
e
s
=
c
u
r
l
e
x
e
c
(
strRes=curl_exec(
strRes=curlexec(ch);
curl_close($ch);
a
r
r
R
e
s
p
o
n
s
e
=
j
s
o
n
d
e
c
o
d
e
(
arrResponse=json_decode(
arrResponse=jsondecode(strRes,true);
if(KaTeX parse error: Expected '}', got 'EOF' at end of input: …('UTF-8','GBK',arrResponse[‘err_msg’])."\n";
}
/** tinyurl */
echo$arrResponse[‘tinyurl’]."\n";
?>
其他接口使用如上