How to pull Sales Report CSV file with PHP and cUrl?

I tried using php and curl but it fails with the “Object moved to …” error message.

Object moved

Object moved to here.

Is there a method to access the Sales Report data without logging into the Developer site and manually downloading the csv file?

I’d really like to make this into an automated process that grabs the sales info every night and imports it into a database table on my server.

example:

// initialize a new curl resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://owner.roku.com/Developer/Reports/Csv’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, “$username:$password”);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $output;
echo “__\n”;
echo print_r($info);

“Pinkie” wrote:
I tried using php and curl but it fails with the “Object moved to …” error message.

Object moved to here.

Is there a method to access the Sales Report data without logging into the Developer site and manually downloading the csv file?

I’d really like to make this into an automated process that grabs the sales info every night and imports it into a database table on my server.

example:

// initialize a new curl resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://owner.roku.com/Developer/Reports/Csv’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, “$username:$password”);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $output;
echo “__\n”;
echo print_r($info);
I don’t think the site uses basic auth to authenticate users. I think you would need to:

  1. Curl the login page: https://owner.roku.com/Login/
  2. Parse the login form to extract the hidden “__RequestVerificationToken” input element.
  3. POST the hidden “__RequestVerificationToken” input, Password and Email inputs(see: http://superuser.com/questions/149329/h … -with-curl)
  4. Store the cookie(s) returned (see: http://ask.metafilter.com/18923/How-do- … -with-CURL)
  5. Finally make the request for the csv, providing the cookie(s) back to roku. It’s been a long time since I’ve used the curl php module, but I believe if you work out the process with the command line version of curl first, you should be able to re-implement it in php.

Thank you, I will give that a try.

I admit I would prefer a system like those used by payment processors (iBill, CCBill, Epoch, etc).