I really wish there was better documentation on this.
I am looking up stats on certain pages and I want to run a loop for each page and run REST API:
foreach($content_posts as $content_post){
$page_url = $content_post->guid;
$page_url = str_replace('http://mysite.com/internal','',$page_url);
echo $page_url . '<br/>';
$url = "http://mysite.com/piwik/";
$url .= "?module=API&method=Actions.getPageUrl";
$url .= "&pageUrl=$page_url&idSite=2&period=range&date=2012-06-01,2012-06-30";
$url .= "&format=PHP";
$url .= "&token_auth=$token_auth";
$fetched = file_get_contents($url);
$content = unserialize($fetched);
// case error
if(!$content)
{
echo "Error, content fetched = ".$fetched;
}
echo var_dump($content) . '<br />';
/*foreach($content as $row)
{
$hits = $row['nb_hits'];
echo '<span class="result">' . $hits . '</span><br />';
}*/
}
var_dump($content) outputs:
Error, content fetched = a:0:{}array(0) { }
What am I doing wrong?