Exemplo n.º 1
0
} catch (Exception $e) {
    echo '<div>' . $e->getMessage() . '</div>';
}
$url = $bitly->shortenSingle('http://www.ruslanas.com');
//$bitly->setReturnFormat('xml');
//echo $bitly->stats($url);
//exit;
// line below generates error
try {
    $bitly->getThumbnail();
} catch (Exception $e) {
    echo '<div>' . $e->getMessage() . '</div>';
}
$bitly->getInfoArray($url);
$bitly->getStatsArray($url);
echo '<h1>' . $bitly->getTitle() . '</h1>';
echo $bitly->getClicks() . ' clicks<br/>';
echo '<img src="' . $bitly->getThumbnail('medium') . '"/>';
echo '<h2>Expanded data</h2>';
echo 'Expanded: ' . $bitly->expandSingle($url);
include 'lib/zzgd.class.php';
$zzgd = new Zzgd();
$short = $zzgd->shortenSingle('http://www.google.com/');
echo '<br/>zz.gd: ' . $short;
echo '<br/>Decrypted: ' . $zzgd->expandSingle($short);
include 'lib/tinyurl.class.php';
$tinyurl = new Tinyurl();
$short = $tinyurl->shortenSingle($url);
echo '<br/><a href="' . $short . '">' . $short . '</a>';
?>
</body>
Exemplo n.º 2
0
// this line generates error INVALID_URI
if (!$bitly->shorten('http:/\\yahoo.com')) {
    echo '<div class="error">' . $bitly->getError() . '</div>';
}
echo $bitly->shortenSingle('http://aerodromes.eu');
$data = $bitly->expand('dT0uqL');
echo '<p>' . $data[0]->long_url . '</p>';
$data = $bitly->lookup(array('http://aerodromes.eu', 'http://google.com'));
if (!$data) {
    echo 'Error: ' . $bitly->getErrorCode() . ' "' . $bitly->getError() . '"';
}
foreach ($data as $rowObj) {
    // check if found
    if (empty($rowObj->error)) {
        $url = $rowObj->short_url;
        $title = $bitly->getTitle($url) or trigger_error('Error: ' . $bitly->getErrorCode());
        echo '<h1><a href="' . $url . '">' . $title . '</a></h1>';
        $clicks = $bitly->clicks($url);
        echo '<p>Global clicks: ' . $clicks[0]->global_clicks . '</p>';
        echo '<table>';
        $referrers = $bitly->referrers($url);
        foreach ($referrers as $refObj) {
            echo '<tr><td>' . $refObj->referrer . '</td><td>' . $refObj->clicks . '</td></tr>';
        }
        echo '</table>';
    } else {
        echo $rowObj->error;
    }
}
?>
</body>