How to store metric output in PHP variable (API)

Hello,
this is my first questions in this forum, i have some question :
1.Can i store metric output to PHP variable ?
ex.
$request = new Piwik_API_Request(‘
method=UserSettings.getResolution
&idSite=7
&date=yesterday
&period=week
&format=HTML
&filter_limit=3
&token_auth=anonymous
’);
$result = $request->process();

how to store metric output e.g. nb_visits in php variable?

  1. Can i customize metric output?

thx for your help :slight_smile:

See the example in http://piwik.org/docs/analytics-api/calling-techniques/

Thx matt for your advice :slight_smile:

but, how to call in PHP?
when is use
$result = $request->process();
echo $result; // call all metric

echo $result->nb_visits ??

$results[‘nb_visits’] ?

echo $result[‘nb_visits’];

print only ‘a’

here’s my full code

define(‘PIWIK_INCLUDE_PATH’, realpath(‘piwik’));
define(‘PIWIK_USER_PATH’, realpath(‘piwik’));
define(‘PIWIK_ENABLE_DISPATCH’, false);
define(‘PIWIK_ENABLE_ERROR_HANDLER’, false);
define(‘PIWIK_ENABLE_SESSION_START’, false);
require_once PIWIK_INCLUDE_PATH . “/index.php”;
require_once PIWIK_INCLUDE_PATH . “/core/API/Request.php”;
Piwik_FrontController::getInstance()->init();
$request = new Piwik_API_Request(‘
method= Actions.getPageUrl
&pageUrl=/index
&idSite=1
&date=today
&period=week
&format=PHP
&token_auth=sumsum
’);
$result = $request->process();
echo $result[‘nb_visits’];

if you do
$result = $request->process();
$result = unserialize($result);
var_dump($result);

you can see the value of the variable and choose which value to use in the array

Wow, thank’s Matt,
you are my lifesaver :slight_smile:

case closed :smiley: