未加星标

Make a Simple URL Shortener with PHP Tutorial (tinyurl)

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Tutorial to Make a Simple URL Shortener withphp-Well we often need URL shortener with PHP for our projects, making tinyurl is important since it is very inconvenient to read long urls and it is not a good sign, it looks like a spammy link. In order to avoid the hassle of sharing ugly urls we can use tinyurls using PHP. We generally make use of Tinyurls when we want to post a link on twitter, however due to character limits we need short urls and thats when URL shortener comes into play.


Make a Simple URL Shortener with PHP Tutorial (tinyurl)

These days many web applications need tinyurls, it loads up site faster and url looks cleaner. In this post I will be sharingURL shortetner method using PHP and cURL. You can use our code it is free you can use it in your projects. We can also customize the URL name. For this tutorial we are going to stick with standard tinyurl.

Check How to send SMS using PHP

Simple Login system in PHP with session

Demo

Simple URL Shortener with PHP Tutorial <?php
function get_tiny_url($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//demo
$new_url = get_tiny_url('http://www.techplugg.com');
echo "Visit Techplugg-"." "."<a href='$new_url'>$new_url</a>";
?>

Everytime we are making request to Tinyurl API and requesting it to change our desired url through cURL function. Everytime it generates a new unique URL.

Contributed by- Satyajit Chitnis

Location- Chennai, India

Also check

Codeigniter Login Logout Tutorial Firebase API using PHP and curl

If you find this post useful then don’t forget to share it with your friends on social networking sites like facebook and twitter as it will only motivate to post more such articles. In the upcoming posts we will share more such posts on PHP till then don’t forget to subscribe.

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

主题: PHPCUOPTUTTI
分页:12
转载请注明
本文标题:Make a Simple URL Shortener with PHP Tutorial (tinyurl)
本站链接:http://www.codesec.net/view/482315.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(28)