Create an Is.Gd URL Using PHP
Is.Gd is a URL-shortening service much like TinyURL. Using PHP's cURL library, you can create shortened URLs on the fly with ease.
The PHP
//gets the data from a URL
function get_isgd_url($url)
{
//get content
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://is.gd/api.php?longurl='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$content = curl_exec($ch);
curl_close($ch);
//return the data
return $content;
}
//uage
$new_url = get_isgd_url('https://davidwalsh.name/php-imdb-information-grabber');
"is.gd" is much shorter than "tinyurl.com" so if you need the URL to be as short as possible, use this method.
One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest
, wasn't really made for what we've been using it for. We've done well to create elegant APIs around XHR but we know we can do better. Our effort to...
Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...
AJAX has become a huge part of the modern web and that wont change in the foreseeable future. MooTools has made AJAX so simple that a rookie developer can get their dynamic pages working in no time.
Step 1: The XHTML
Here we define two links...
One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?
They do supply an API, you know: http://is.gd/api_info.php
Ah, I’m glad you did this.
is.gd is my URL ‘shortener’ of choice. :)
I’m looking forward to the re-design too BTW!
‘Is.gd’ has an API! :-)
This URL will return just the shortened URL: (no confirmation message)
http://is.gd/api.php?longurl=http://www.example.com
Thanks for the tip guys. I’ve adjusted my article accordingly.
Hi, How do you highlight PHP syntax in the example above?
Could you show me a list of WordPress plugins you are using on this blog?
Thanhks
:)