public function testGetJSONReturnsValidJSON() { global $CONFIG; $jsonCache = new JsonCache(); $API_CALL = "/wp-json/posts?filter[orderby]=date&filter[posts_per_page]=3"; $queryURL = $CONFIG['blogURL'] . $API_CALL; $result = json_decode($jsonCache->get_json($queryURL, $CONFIG['cacheDir'], $CONFIG['cacheExpires'])); $this->assertInternaltype('array', $result); }
<?php $API_CALL = "/wp-json/posts?filter[orderby]=date&filter[posts_per_page]=3"; require_once 'includes/config.php'; require_once 'includes/jsonCache.php'; $jsonCache = new JsonCache(); $queryURL = $CONFIG['blogURL'] . $API_CALL; $topnews = json_decode($jsonCache->get_json($queryURL, $CONFIG['cacheDir'], $CONFIG['cacheExpires'])); //template for output foreach ($topnews as $item) { ?> <a href="post.php?id=<?php echo $item->ID; ?> "> <?php echo $item->title; ?> </a> <br> <?php }