Archive

Posts Tagged ‘franck’

SmartShanghai.com now using LiURL

April 21st, 2009

SmartShanghai.com is now using LiURL.cn to generate small url’s for all their twitter links.

frank

Its not immediately obvious, but if you click on the Twitter link (example below), you’ll see LiURL in use.

twitter

We worked with SmartShanghai in order to assist them with integration. SmartShanghai’s original plan was to run a script to generate url’s for all 5000+ venues. While this would have worked, it wasn’t an optimal solution for either site.

Our revised design works something like this.

On page load, SmartShanghai checks to see if they have a small url for the page in their database.
If they don’t, they call LiURL’s API (http://liurl.cn/api-create.php?url=[YOURURL]) to generate a Little URL, and save the URL locally in their database.

Simple, and elegant. URL’s are generated only once, on a page request by a user.

If you would like to use LiURL.cn in your site, let us know, and we can assist with integration.

For the technically inclined, sample PHP code to use LiURL.cn is below.

<?php

//Use cUrl to retrieve content
function get_content($url) {
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec ($ch);
curl_close ($ch);
$string = ob_get_contents();
ob_end_clean();
return $string;
}

//URL = url to encode
$url="http://www.example.com";

//Call the LiURL api
$content = get_content ("http://liurl.cn/api-create.php?url=". $url);

//Show our short url
echo $content;

?>
 

admin API, Site Related , , , ,