开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 6346|回复: 3
收起左侧

[其它] 推荐短网址合集接口

[复制链接]
发表于 2020-9-22 12:44:03 | 显示全部楼层 |阅读模式   河北省邯郸市
不会PHP的可以http://dwz.nyun.cc/这里生成
具体接口'tcn','urlcn','t360','sinaurl','wurl','mrw','suoim','suonz','unu','gitio','surl','vurl','zz3','syam'
  1. <?php
  2. header("Content-Type:text/json; charset=utf-8");
  3. $dwzapiall = array('tcn','urlcn','t360','sinaurl','wurl','mrw','suoim','suonz','unu','gitio','surl','vurl','zz3','syam');
  4. $longurl = (isset($_GET['url'])) ?$_GET['url']:$_POST['url'];
  5. $dwzapi = (isset($_GET['dwzapi'])) ?$_GET['dwzapi']:$_POST['dwzapi'];

  6. if(!$longurl||!$dwzapi){
  7. exit (returnMsg(-1, "生成失败", '参数不完整'));
  8. }else if(strpos($longurl,".") == false){
  9. exit (returnMsg(-1, "生成失败", 'URL格式错误'));
  10. }if (!preg_match('/^http[s]?:\\/\\//', $longurl)) {
  11.     $longurl = "http://" . $longurl;
  12.     return true;
  13. }

  14. if (in_array($dwzapi, $dwzapiall)) {
  15. $dwzurl = dwz($longurl,$dwzapi);
  16. if($dwzurl){exit (returnMsg(0, "生成成功", $dwzurl));
  17. }else{exit (returnMsg(-1, "生成失败", '接口生成失败'));}
  18. }else{exit (returnMsg(-1, "生成失败", '短网址参数错误'));}

  19. function dwz($longurl,$dwzapi)
  20. {
  21.     $url = 'http://api.nyun.cc/dwz/index.php?url='.urlencode($longurl).'&dwzapi='.$dwzapi;
  22.     $result = curl($url);
  23.     $arr = json_decode($result, true);
  24.     $result = $arr['data'];
  25.     if (!$result) {
  26.     } else {
  27.         return $result;
  28.     }

  29. }


  30. function returnMsg($code, $msg, $data)
  31.     {
  32.         return json_encode(['code'=>$code, 'msg'=>$msg, 'data'=>$data], JSON_UNESCAPED_UNICODE);
  33.     }
  34.      

  35. function curl($url, $method='GET', $params=array(), $getinfo=false)
  36.     {
  37.         $header = array();
  38.         if(isset($params["header"])){
  39.             $header = array_merge($header,$params["header"]);
  40.         }
  41.         $user_agent = empty($params["ua"]) ? 0 : $params["ua"] ;
  42.         $ch = curl_init();                                                     
  43.         curl_setopt($ch, CURLOPT_URL, $url);                                   
  44.         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  45.         if($params["ref"]){
  46.             curl_setopt($ch, CURLOPT_REFERER, $params["ref"]);
  47.         }
  48.         if (array_key_exists('responseHeader', $params) && $params['responseHeader']) {
  49.             curl_setopt($ch, CURLOPT_HEADER, true);
  50.             curl_setopt($ch, CURLOPT_NOBODY, true);
  51.         }else {
  52.             curl_setopt($ch, CURLOPT_NOBODY, false);
  53.         }
  54.         curl_setopt($ch, CURLOPT_USERAGENT,$user_agent);                                                  
  55.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                        
  56.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);                       
  57.         curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
  58.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                       
  59.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);                       
  60.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);                        
  61.         curl_setopt($ch, CURLOPT_AUTOREFERER, true);                           
  62.         curl_setopt($ch, CURLOPT_ENCODING, '');                        
  63.         if($method == 'POST'){
  64.             curl_setopt($ch, CURLOPT_POST, true);              
  65.             curl_setopt($ch, CURLOPT_POSTFIELDS, $params["postData"]);               
  66.         }
  67.         $res = curl_exec($ch);
  68.         if ($getinfo) {
  69.             $data = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
  70.         }else {
  71.             $data = $res;
  72.         }
  73.         curl_close($ch);                                                      
  74.         return $data;
  75.     }
  76.     ?>
复制代码



签到天数: 6 天

发表于 2022-10-28 22:59:02 | 显示全部楼层   辽宁省营口市
6666666666666
回复 支持 反对

使用道具 举报

发表于 2020-9-27 14:29:23 | 显示全部楼层   吉林省长春市
有用!!!感谢分享!!!
回复 支持 反对

使用道具 举报

结帖率:100% (3/3)

签到天数: 19 天

发表于 2020-9-25 19:08:10 | 显示全部楼层   广东省湛江市
感谢楼主的分享
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表