Exemple #1
0
<?php

require_once "../main.php";
try {
    $Client = new REST_CLIENT();
    $Client->setMethod(REST_CLIENT::METHOD_GET);
    // This is not required because the default method is GET
    $Client->setParams(array('vq' => 'codecanyon', 'orderby' => 'viewCount'));
    $result = $Client->request('http://gdata.youtube.com/feeds/api/videos', REST_CLIENT::CONTENT_XML);
    // Show results
    echo '<ul>';
    foreach ($result->entry as $item) {
        echo '<li><a href="' . $item->link[0]['href'] . '">' . trim($item->title) . '</a></li>';
    }
    echo '</ul>';
} catch (Exception $e) {
    echo 'YouTube seems to be offline!';
}
Exemple #2
0
<?php

require_once "../../main.php";
define("GOOGLE_API", "AIzaSyDEqBO9D1tLqSdX3QOtqy6-ZfotMZ5e-6A");
$client = new REST_CLIENT();
$client->setMethod(REST_CLIENT::METHOD_POST);
$client->addParam("longUrl", "http://www.amitinside.com/");
$client->addParam("key", GOOGLE_API);
$result = $client->request("https://www.googleapis.com/urlshortener/v1/url", REST_CLIENT::CONTENT_JSON);
explode($result);