--- layout: post title: 让Git.io无限制 tags: [无限制, Git.io, Github] --- 如何让Git.io没有只能创建Github.com网站链接的限制呢? 众周所知,[Git.io](https://Git.io)是一个不错的生成短链接的网站,由Github提供([相关链接](https://github.blog/2011-11-10-git-io-github-url-shortener/)) 然而Git.io只能缩短Github域名的网址。 我还是挺喜欢Git.io这个域名的,尽管它比t.cn这种链接要长,但是Git(愚蠢)听起来就是很有意思啦23333 所以我想了一个办法来解决Git.io只能创建Github.com网站链接的限制。 演示效果: (尽管很想搞一个能自定义Git.io链接的选项,可惜我前端不好LOL) (其实要不是因为CORS这种问题,就不用PHP来浪费资源了……) # Code (由于此脚本被滥用导致本博客被删,此服务将不再提供,以下脚本仅作记录) ## 1.gitio.php ```php array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 15 * 60 ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; } if(get_headers($url)) { $post_data = array('url'=>"https://mabbs.github.io/jump.html?url=".$url ); $talkContent = send_post('https://git.io/create', $post_data); header('text/html; charset=utf-8'); header('Access-Control-Allow-Origin: *'); echo $talkContent; } else { header('HTTP/1.1 500 Internal Server Error'); header('text/html; charset=utf-8'); header('Access-Control-Allow-Origin: *'); echo "Invalid url: ".$url; } ?> ```