Unlike bit.ly, tinyurl, or any of the other 50 services, su.pr is the first URL shortener to also syndicate content. I’m a bit late in posting about this but they did a terrific job on their URL shortener. The catch here is that it also syndicates in StumbleUpon (SU) which is absolutely kick ass. You know what that means? More traffic, a content-rich SU blog, and more links into the Internet.

This handy snippet of code will take the $url variable and churn it through the system to generate your new $SU_newURL.

 PHP |  copy code |? 
01
02
// Set username and password
03
$SU_username = "username";
04
$SU_api = "34827348732fakekey";
05
 
06
// The SUPR API address
07
$SU_url = "http://su.pr/api";
08
 
09
// URL to Shorten
10
$SU_shortUrl="$url";
11
 
12
// Combine URL
13
$SU_vars = "?url=$SU_shortUrl&login=$SU_username&apiKey=$SU_api";
14
 
15
// Set up and execute the curl process
16
$curl_handle = curl_init();
17
curl_setopt($curl_handle, CURLOPT_URL, $SU_url . $SU_vars);
18
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
19
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
20
curl_setopt($curl_handle, CURLOPT_HTTPGET, 1); 
21
$buffer = curl_exec($curl_handle);
22
curl_close($curl_handle);
23
/*
24
// check for success or failure
25
if (empty($buffer)) {
26
    echo 'message';
27
} else {
28
    echo $buffer;
29
}
30
*/
31
 
32
//$SU_newURL = str_replace("su.pr/", "", $buffer);
33
 
34
echo $SU_newURL;
35

This part here is optional:

 PHP |  copy code |? 
1
2
$SU_newURL = str_replace("su.pr/", "", $buffer);
3

When you use the "sync" or host the shortened URL on your own domain through the su.pr .htaccess mods, it returns the hash and link as http://su.pr/domain.com/hash_key

That can kind of mess things up. All the optional code does is extra the su.pr out.
Was this useful? Help share it:
  • Print this article!
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Mixx
  • Fark
  • MySpace
  • Technorati
  • Reddit