Created
March 29, 2010 13:12
-
-
Save yaroot/347818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function twitter_url_shorten_callback($match) { | |
if (preg_match('#http://www.flickr.com/photos/[^/]+/(\d+)/#', $match[0], $matches)) { | |
return 'http://flic.kr/p/'.flickr_encode($matches[1]); | |
} | |
/* | |
if (!defined('BITLY_API_KEY')) return $match[0]; | |
$request = 'http://api.bit.ly/shorten?version=2.0.1&longUrl='.urlencode($match[0]).'&login='.BITLY_LOGIN.'&apiKey='.BITLY_API_KEY; | |
$json = json_decode(twitter_fetch($request)); | |
if ($json->errorCode == 0) { | |
$results = (array) $json->results; | |
$result = array_pop($results); | |
return $result->shortUrl; | |
} else { | |
return $match[0]; | |
} | |
*/ | |
if (!defined('GOOGLE_URL_SHORTENER')) return $match[0]; | |
$request = 'http://ggl-shortener.appspot.com/?url='.urlencode($match[0]); | |
$json = json_decode(twitter_fetch($request));//lzq | |
if (!isset($json->error_message)) { | |
return $json->short_url; | |
} else { | |
return $match[0]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment