Ticket #253 (closed Bug: invalid)

Opened 4 months ago

Last modified 3 months ago

Calling API returns error message

Reported by: lorenzoferrara Assigned to:
Priority: major Milestone: RobotRock
Component: Core Version:
Keywords: auth_token, api Cc:

Description

Hello, I've created a new PHP script which calls Piwik_API_Request. I've included the token_auth variable in the call but I keep getting:

Array ( [result] => error [message] => You can't access this resource as it requires a 'view' access for the website id = 2. )

This is part of the code:

define('PIWIK_INCLUDE_PATH', '.');
define('ENABLE_DISPATCH', false);    
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/modules/API/Request.php";

Piwik_FrontController::getInstance()->init();

$request = new Piwik_API_Request ("method=VisitsSummary.get
                &idSite=$idsite
                &period=year
                &date=last2
                &format=PHP
                &serialize=0
                &prettyDisplay=0
                &token_auth=$token_auth");

$result = $request->process();

print_r($result);

The call doesn't produce any error if I'm logged in.

Change History

06/30/08 00:46:25 changed by matt

  • status changed from new to closed.
  • resolution set to invalid.
  • milestone set to RobotRock.

Have you used the token that you get when you are logged in, by going to the API section?

It loooks like you are using a token from a user who doesn't have enough permission on this website. reopen if i'm wrong.

06/30/08 10:01:25 changed by lorenzoferrara

I use the tocken provided when I'm logged in as administrator.