简介
欢迎您选择本程序进行短网址转换,通过该接口可以将长链接转换为短链接模式;违规链接我们将采取举报、拉黑域名方式处理!
使用说明
参数 |
说明 |
接口地址 |
http://suo.to/api.html |
请求方式 |
支持 GET 请求 |
返回格式 |
JSON |
请求参数
参数 |
类型 |
说明 |
是否必须 |
url |
String |
http://www.xinxilanyimin.com/content/60.html |
是 |
示例代码
$url = 'http://www.xinxilanyimin.com/content/60.html'; // 随机链接
$data = curl_get($url);
var_dump($data);
/**
* curl get 请求
* @param $url
* @return bool|string
*/
function curl_get($url)
{
// 初始化
$ch = curl_init();
// 设置变量
curl_setopt($ch, CURLOPT_URL, sprintf('http://suo.to/v1/api.html?url=%s', $url));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
// 执行并获取结果
$output = curl_exec($ch);
// 释放cURL句柄
curl_close($ch);
return $output;
}
返回样例
{
"code":200,
"message":"success",
"data":"http://suo.to/EFOUhl"
}
错误信息
错误码 |
说明 |
100 |
缺失链接参数 |
101 |
此域名已被拉黑 |