全球主机交流论坛

标题: 有没有短域名还原解析的源码? [打印本页]

作者: sohu    时间: 2018-12-7 11:15
标题: 有没有短域名还原解析的源码?
就是把短域名转成真实地址的源码?
作者: sohu    时间: 2018-12-7 11:36
这个没有开源的吗?
作者: 勇气    时间: 2018-12-7 11:39
http://www.wheregoes.com/

这个可以还原,但是没找到源码
作者: coobar    时间: 2018-12-7 11:41
https://duanwangzhihuanyuan.51240.com/

这里还原
作者: sohu    时间: 2018-12-7 15:35
要源码呀,有没有
作者: flofire    时间: 2018-12-7 16:02
  1. <?php

  2. function restoreSinaShortUrl($shortUrl = '')
  3. {
  4.         $url = "https://api.weibo.com/2/short_url/expand.json?source=2815391962&url_short={$shortUrl}";
  5.         $urlInfo = file_get_contents($url);
  6.         if ($urlInfo){
  7.                 $urlInfo = json_decode($urlInfo, true);
  8.                 if (!json_last_error() && isset($urlInfo['urls'])){
  9.                         return $urlInfo['urls'][0]['url_long'];
  10.                 }
  11.         }
  12.         return false;
  13. }

  14. //还原短链接
  15. //http://t.cn/zWCJpzQ
  16. function getRealUrl($url)
  17. {
  18.         while(true){
  19.                 if (strstr($url, 'http://t.cn/')){
  20.                         $url = restoreSinaShortUrl($url);
  21.                 } else {
  22.                         break;
  23.                 }
  24.         }
  25.         return $url;
  26. }
复制代码

作者: sohu    时间: 2018-12-7 18:00
flofire 发表于 2018-12-7 16:02

这只有一种后缀?想找个成品的开源,直接放上去用那种
作者: 虚拟    时间: 2018-12-7 18:07
用PHP 去模拟跑一下网址,在把网址显示出来..




欢迎光临 全球主机交流论坛 (https://loc.mjj8.eu.org/) Powered by Discuz! X3.4