Добавляем след. в functions.php шаблона:
//create bit.ly url
function bitly()
{
//login information
$url = get_permalink(); //generates wordpress' permalink
$login = 'XXX'; //your bit.ly login
$apikey = 'XXX'; //bit.ly apikey
$format = 'json'; //choose between json or xml
$version = '2.0.1';
//create the URL
$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$apikey.'&format='.$format;
//get the url
//could also use cURL here
$response = file_get_contents($bitly);
//parse depending on desired format
if(strtolower($format) == 'json')
{
$json = @json_decode($response,true);
echo $json['results'][$url]['shortUrl'];
}
else //xml
{
$xml = simplexml_load_string($response);
echo 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
}
}
показ в шаблоне вызывается так:
<?php bitly(); ?>
23.11.2011
Раздел(ы):
Метки:

собственно сабж - засим решил проверить этим постом фишку QuickPress, а еще добавили Press This ...оО ... полезный штук =)








1 GBP - 47,0056 руб.
1 USD - 29,7692 руб.
1 EUR - 39,4114 руб.