Beispiel #1
0
function outputTrends($format = 'json')
{
    $trends = getTrends($format);
    if (!isset($trends->trends)) {
        return false;
    }
    $html = '';
    foreach ($trends->trends as $trend) {
        $li = '
				<li>
				<a href="search.php?q=' . rawurlencode($trend->name) . '">' . $trend->name . '</a>
				</li>
				';
        $html .= $li;
    }
    return $html;
}
Beispiel #2
0
require_once 'Unirest/Response.php';
require_once 'Unirest/Request.php';
//
$host = 'courant.com';
//
$apiKey = 'xxx';
//
$sections = ['news' => 'news,breaking-news,politics', 'sports' => 'sports', 'business' => 'business', 'entertainment' => 'entertainment'];
//
$all_sections = ['news' => [], 'sports' => [], 'business' => [], 'entertainment' => []];
//
$collection = ['news' => 'hc_trending_news', 'sports' => 'hc_trending_sports', 'business' => 'hc_trending_business', 'entertainment' => 'hc_trending_entertainment'];
$MAX_RESULTS = 10;
//
foreach ($sections as $key => $value) {
    getTrends($key, $value);
}
/********************************************************/
/*** Insert into p2p collection**************************/
/********************************************************/
// populate each collections
foreach ($collection as $key => $value) {
    // set url to the appropriate collection
    $P2Purl = "http://content-api.p2p.tribuneinteractive.com/collections/override_layout.json?id=" . $value;
    //
    $data["items"] = array();
    //
    $i = 0;
    foreach ($all_sections[$key] as $slugs) {
        if ($i < $MAX_RESULTS) {
            $arr = array("slug" => $slugs);