Actions.getPageUrl help

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?

Is there a Piwik server running at: x
Works for me well ?

Yes, there’s a server. Do me a favor and remove that URL reference. I forgot to strip that out when I C + P’d the code. Thanks.

Try to urlencode($page_url) in the code ?

Can you please remove the URL that you referenced in your previous post?

Done