Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Pinkie
Visitor

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.

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/Login/?ReturnUrl=%2fDeveloper%2fReports%2fCsv">here</a>.</h2>
</body></html>

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);
Pink Visual
We Innovate, You Masturbate
0 Kudos
2 REPLIES 2
gonzotek
Visitor

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

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

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/Login/?ReturnUrl=%2fDeveloper%2fReports%2fCsv">here</a>.</h2>
</body></html>

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.
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
0 Kudos
Pinkie
Visitor

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

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).
Pink Visual
We Innovate, You Masturbate
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.