用php代码需要有样式接口地址:httpstapiicn返回格式:JSON请求方式:GET 暂无层级展示仅供参考 code 状态码 msg 生成状态 url 生成链接
"https://www.baidu.com", //需要缩短的链接
"type" => "json" //返回格式为JSON
);
//发送请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($params)); //拼接请求参数
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
//解析返回结果
$result = json_decode($output, true);
if($result['code'] == 200){
//生成成功,输出短链接
echo "
{$result['msg']},短链接为:{$result['url']}
";
}else{
//生成失败,输出错误信息
echo "{$result['msg']}
";
}
?>
原文地址: https://www.cveoy.top/t/topic/M5Y 著作权归作者所有。请勿转载和采集!