Maddyhome Forums

Discussions related to software developed at maddyhome.com
It is currently Fri Sep 03, 2010 3:37 am

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Downloading Sales/Trend Reports
PostPosted: Mon Aug 25, 2008 5:42 pm 
Offline
Site Admin

Joined: Thu Aug 14, 2008 3:26 pm
Posts: 530
Here is a bash shell script that will allow you to automate the downloading of daily Sales/Trend Reports from Apple. I am making this available as a courtesy to other developers but it is not supported in any way and I do not plan on maintaining it. Use this for your own use and your own risk.

This script just downloads the data. That's it. What you do with it is up to you.

UPDATE: 2008-09-24: This script stopped working last week. Thanks to Mike Greiner the script has been fixed. The attachment has been updated with the new script.

UPDATE: 2008-12-08: Apple changed some field names again 3 days ago. Updated script to work with the changes.

UPDATE: 2009-12-12: Apple changed some field names again on Nov 18, 2009. Updated script to work with the changes.

Enjoy.


Attachments:
download.sh.zip [2.04 KiB]
Downloaded 97 times
Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Wed Aug 27, 2008 8:18 pm 
Offline
Site Admin

Joined: Thu Aug 14, 2008 3:26 pm
Posts: 530
Another iPhone developer has put together a php script that gives a summary of the sales/trend data. If you use my script as a cron job to download the data daily and install this php script on a local web server you can easily view your data. You can get the php script here:

http://www.ezone.com/download/iphonereports.zip

Link posted with permission.


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Thu Aug 28, 2008 11:23 am 
Offline

Joined: Thu Aug 28, 2008 11:20 am
Posts: 8
Rick,

First, thanks for this.

Second, I can't get it to work :/

I am thinking that it is for an older verion of the piano interface..

does this still work for you?


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Thu Aug 28, 2008 8:54 pm 
Offline
Site Admin

Joined: Thu Aug 14, 2008 3:26 pm
Posts: 530
It worked for me today getting data for the 27th. In some cases the calculation of yesterday's date at the top of the script doesn't work right and returns today's date. If that happens it won't work too well since there is no data for 'today'.

How far does the script get for you? Comment out the various 'rm -f' lines and look at the out put of each 'curl' call.


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Fri Aug 29, 2008 10:52 am 
Offline

Joined: Thu Aug 28, 2008 11:20 am
Posts: 8
it seems to fail during the "select vendor form post" do you have this setup in your portal? we only have one vendor ourselves but nevertheless we have to select it.

some logging:

mike@Jeter :> bash download.sh
Getting sales and trend data for 08/28/2008
loginscreen.html ACTION
/WebObjects/MZLabel.woa/wo/0.0.5.1.3.3.1.0.1
homapage.html ACTION
/WebObjects/MZLabel.woa/wo/2.0.5.1.5.2.7.1.0.0.3
salestrend.html ACTION (Why is it empty?)

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 301 0 301 0 0 908 0 --:--:-- --:--:-- --:--:-- 0
Data for 2008-08-28 has been saved to 2008-08-28-data.csv.gz


I don't get back a gzip file but a file that is named above..

in that file I get this:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>405 Method Not Allowed</TITLE>
</HEAD><BODY>
<H1>Method Not Allowed</H1>
The requested method POST is not allowed for the URL /index.html.<P>
<HR>
<ADDRESS>Apache/1.3.33 Server at itts.apple.com Port 8154</ADDRESS>
</BODY></HTML>


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Fri Aug 29, 2008 12:58 pm 
Offline
Site Admin

Joined: Thu Aug 14, 2008 3:26 pm
Posts: 530
When I log into iTunes Connect I don't need to select a vendor. Since your flow is different you will need to modify the script to handle the extra screen.


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Fri Aug 29, 2008 2:33 pm 
Offline

Joined: Thu Aug 28, 2008 11:20 am
Posts: 8
yeah, I am confused about how to set the correct fields, form info like you do below..

#curl --cookie-jar cookies --cookie cookies --location-trusted -e ";auto" -d "9%2e5=Summary" -d "9%2e7=Daily" -d"9%2e9%2e1=${YEST}" -d "hiddenDayOrWeekSelection=${YEST}" -d "hiddenSubmitTypeName=Preview" -d "preview=Preview" "https://itts.apple.com${ACTION}" -o preview.html

where do you get "9%2e5" the vendor page is just three fields. the first field being a select box, the second field is just a textbox that gets auto-populated with what you choose from the first fields select box and the third field is a select box that says "select territory" but there is nothing in it to select.

I took a snapshot of the form variables... I have no idea how to shape the url for curl to use correctly. I appreciate all your help..
http://www.flickr.com/photos/30020071@N04/2809609184/sizes/o/

FYI, the vendor page comes right after I select "sales/trending" from the list after the login page, then when I select the vendor page it takes me to a page that has 2 links.. one for 'transactions' and another for 'financials' then I click on transactions which takes me to the 'report options' page..

Can you help me puzzle out the building of the URI or the passing of the correct variables?

Thanks again!


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Sat Aug 30, 2008 9:09 am 
Offline
Site Admin

Joined: Thu Aug 14, 2008 3:26 pm
Posts: 530
The '%2e' represents a period so the actual string is '9.5'.

Keep in mind that there are hidden form fields that you can't see. They are in the HTML source as <input type='hidden'...>. These need to be set just as much as the visible ones. In your picture at the bottom is a list of elements. You need a '-d' argument for each 'name' column. So you need:

-d "9.6.0=whatever" -d "vndrid=whatever"

And the rest too including the submit button (but not clear).

Your screens are very different from mine. I don't have a vendor screen.

Good luck.


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Sat Aug 30, 2008 4:46 pm 
Offline

Joined: Thu Aug 28, 2008 11:20 am
Posts: 8
Rick I am going nuts.

so just for the heck of it I tried using "lynx" and when I get to the vendor page to submit the form it does not go to another page. I thinking there is some ajax/weirdness. when I use safari/ff I select the vendor name and it populates the vendorId field with the vendorId number.. but you can't enter it, it seems to be a read-only text box.

here is the HTML to the page:

<snip>
<HTML>
<HEAD>
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=UTF-8">
<TITLE>iTunes Label Connect</TITLE>
<LINK HREF="/WebObjects/piano.woa/Contents/WebServerResources/iTMSApplication.css" TYPE="text/css" REL="STYLESHEET">

<script language="javascript">
//function vndrID()
//{
// var vendorID;
// if(document.getElementById('vendorId').value!="")
// {
// document.superPage.submit();
// }
// else
// {
// return false;
// }
//}

var flag;

function vndrID()
{
flag="true";
var vendorID;
if(document.getElementById('vendorId').value!="")
{
document.superPage.submit();
return false;
}
else
{
return false;
}
}


function checkVendorIdNumber()
{
if(event.keyCode >=48 && event.keyCode <=57)
{
event.returnValue = true;
}
else if(event.keyCode == 8 )
{
event.returnValue = true;
}
else if(event.keyCode == 9 )
{
event.returnValue = true;
}
else if(event.keyCode == 13)
{
event.returnValue = true;
}
else if(event.keyCode == 63234)
{
event.returnValue = true;
}
else if(event.keyCode == 63235)
{
event.returnValue = true;
}else if(event.keyCode == 63272)
{
event.returnValue = true;
}
else
{
event.returnValue = false;
}
}


function validateData()
{
if(document.getElementById('roleHidden').value == 2)
{
if(document.getElementById('vendorName').value=="" && document.getElementById('vendorId').value=="")
{
alert("Please select a vendor")
return false;
}
else if(document.getElementById('vendorId').value=="")
{
alert("Please select a vendor ID")
return false;
}

}

if(flag!="true")
{
if(document.getElementById('roleHidden').value == 1)
{
if(document.getElementById('selectName').value=="null")
{
alert("Please select a vendor");
return false;
}
if(document.getElementById('selectName').value!="null" && document.getElementById('selCountry').value=="1")
{
alert("Please wait until page refresh");
return false;
}
}

else
{

if(document.getElementById('vendorName').value=="")
{
alert("Please select a vendor");
return false;
}
}

if(document.getElementById('vendorId').value=="")
{
alert("Please select a vendor ID");
return false;
}
if(isNaN(document.getElementById('vendorId').value))
{
alert("Invalid data format.\n\nOnly numbers are allowed.");
document.superPage.vndrid.focus();
return false;
}

if(document.getElementById('selCountry').value=="null")
{
alert("Please select a Territory");
return false;
}

}
else
{
return false;
}
}

function pickerValue()
{
document.getElementById('vendorId').value="";
document.superPage.submit();
}


function clearFields()
{
var browserType = navigator.userAgent;
tempVersion = navigator.userAgent.split("/");
var iIE = browserType.indexOf("IE");

combo = document.getElementById('selCountry');
combo.options.length = 0;
ele = document.createElement('option');
ele.text="Select Territory";

if(iIE > -1)
{
//ele.value="1";
combo.add(ele,1);
}

else
{
ele.value="1";
combo.appendChild(ele);
}

if(document.getElementById('roleHidden').value == 1)
{
document.getElementById('selectName').value="null";
document.getElementById('vendorId').value="";
}
else
{
document.getElementById('vendorName').value="";
document.getElementById('vendorId').value="";
}
return false;
}

function getPapulateValues()
{

var browserType = navigator.userAgent;
tempVersion = navigator.userAgent.split("/");
var iIE = browserType.indexOf("IE");

combo = document.getElementById('selCountry');
combo.options.length = 0;
ele = document.createElement('option');
ele.text="Select Territory";

if(iIE > -1)
{
//ele.value="1";
combo.add(ele,1);
}

else
{
ele.value="1";
combo.appendChild(ele);
}


if(document.getElementById('selectName').value=="null")
{
document.getElementById('vendorId').value="";
return false;
}
else
{
document.getElementById('vendorId').value = document.getElementById('selectName').value;
document.superPage.submit();
}
}

</script>
</HEAD>

<BODY BGCOLOR="#FFFFFF" LEFTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" RIGHTMARGIN="0">


<LINK HREF="/WebObjects/piano.woa/Contents/WebServerResources/iTMSApplication.css" TYPE="text/css" REL="STYLESHEET">

<CENTER>
<div style="width:100%;background-color:#ffffff; float: middle;"><img src="/WebObjects/piano.woa/Contents/WebServerResources/spacer.gif" width="1" height="8"><br>
<div id="globalheader" class="ipoditunes">
<ul id="globalnav">
<li id="gn-apple"><a href="http://www.apple.com/">Apple</a></li>
<li id="gn-store"><a href="http://store.apple.com/">Store</a></li>
<li id="gn-mac"><a href="http://www.apple.com/mac/">Mac</a></li>
<li id="gn-ipoditunes"><a href="http://www.apple.com/itunes/">iPod + iTunes</a></li>
<li id="gn-iphone"><a href="http://www.apple.com/iphone/">iPhone</a></li>
<li id="gn-downloads"><a href="http://www.apple.com/downloads/">Downloads</a></li>
<li id="gn-support"><a href="http://www.apple.com/support/">Support</a></li>
</ul>
<div id="globalsearch">
</div>
</div>
</div>
</CENTER>
<input Id="roleHidden" type="hidden" value="1" name="2"><input type="hidden" name="3">

<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0 WIDTH="99%">
<TR>
<TD ALIGN=center>

<table cellspacing="0" border="0" cellpadding="0" align="center" width="735">
<tr>
<td width="18"></td>
<td width="349"></td>
<td width="19"></td>
</tr>
<tr>
<td></td>
<td colspan="1">

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>

<td><img src="/WebObjects/piano.woa/Contents/WebServerResources/txt_title_itunesvips.gif" alt="iTunes VIPs" border="0"></td>
<td align="right">
<img src="/WebObjects/piano.woa/Contents/WebServerResources/spacer.gif" width="290" height="25" border="0">
<form method="post" name="SignOut" action="/cgi-bin/WebObjects/Piano.woa/3/wo/MJejT3W9gBdgLY53L5o6g0/2.5">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><font color="gray">trends@MyName.com</font></td>
</tr>

<tr>
<td><font color="gray">MyName</font></td>
</tr>

<tr>
<td><input type="submit" value="Sign Out" name="SignOt"></td>
</tr>
</table>
</form>

</td>



</tr>
</table>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="gray"><b>Reporting &gt; Vendor Selection</b></font><br>

</td>
<td>
</td>
</tr>


<tr>
<td background="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_top.gif" align="left" width="18"><img src="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_topl.gif" width="18" height="15" alt="" border="0"></td>
<td background="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_top.gif"><img src="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_top.gif" height="15" width="698" alt="" border="0"></td>
<td align="left"><img src="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_topr.gif" width="19" height="15" alt="" border="0"></td>
</tr>
<form method="post" name="superPage" enctype="multipart/form-data" action="/cgi-bin/WebObjects/Piano.woa/3/wo/MJejT3W9gBdgLY53L5o6g0/2.9">
<tr>
<td background="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_l.gif"></td>
<td colspan="1">

<table cellspacing="0" border="0" cellpadding="5" align="center" width="99%">
<tr>
<td ></td>
<td ><font color="#333333" size="4"><strong>Vendor Options</strong></font><br></td>
</tr>
<tr align="center">
<td colspan="2"><font size="2" color="red"></font></td><br>
</tr>
<tr valign="middle">
<td align="right" width="40%">
<b>Vendor Name:&nbsp;&nbsp;&nbsp;&nbsp;</b>
</td>
<td colspan="2"><table valign="middle" align="left" cellspacing=0 cellpadding=0 ><tr>
<td>
<select style="width:153px" Id="selectName" onChange="getPapulateValues()" name="9.6.0">
<option value="null">Select Vendor</option>
<option selected value="32136242">MyName (32136242)</option></select></td>
<td align="center" valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;</td>

</tr></table></td>
</tr>

<tr><td></td><td></td></tr>
<tr>
<td align="right">
<b>Vendor ID:&nbsp;&nbsp;&nbsp;&nbsp;</b>
</td>
<td align="left" valign="middle">

<input READONLY="true" onKeyPress="return checkVendorIdNumber(event);" Id="vendorId" onChange="return vndrID();" type="text" value="32136242" name="vndrid">
</td>

</tr>
<tr>
<td align="right">
<b>Territory:&nbsp;&nbsp;&nbsp;&nbsp;</b><br><br>
</td>
<td align="left">
<p></p><select id="selCountry" name="Select1">
<option value="999998.0">All Territories</option></select><p></p>&nbsp;&nbsp;
</td>
</tr>

</table>
<center><table style="margin-top: 20px;">
<tr>
<td><a href="mailto:itunesondemand@apple.com"><img border="0" src="/WebObjects/piano.woa/Contents/WebServerResources/btn_help.gif"></a></td>
<td>If you have <a href="mailto:itunesondemand@apple.com">feedback</a> or <a href="mailto:itunesondemand@apple.com">questions</a> please let us know.</td>
</tr>
</table>
</center>

</td>
<td background="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_r.gif"></td>
</tr>
<tr>
<td background="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_bot.gif" align="left"><img src="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_botl.gif" width="18" height="15" alt="" border="0"></td>
<td background="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_bot.gif"><img src="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_bot.gif" height="15" width="698" alt="" border="0"></td>
<td align="left"><img src="/WebObjects/piano.woa/Contents/WebServerResources/box_gray_botr.gif" width="19" height="15" alt="" border="0"></td>
</tr>
<tr><input Id="hiddenCountryName" type="hidden" name="9.18"> <table cellspacing="0" border="0" cellpadding="5" align="center" width="735"> <tr><td
align="right"><input onclick="return validateData()" type="submit" value="Submit" name="SubmitBtn"><input onClick="return clearFields()" type="submit" value="Clear" name="9.21"></td> </tr> </table><td></td><td></td></tr>
</form>
</table>
</td>
</tr>
</TABLE>

</BODY> </HTML>

<div class="footerLinks" align="center"><a href="/cgi-bin/WebObjects/Piano.woa/3/wo/MJejT3W9gBdgLY53L5o6g0/2.11.1">Home</a> <!--| <a href="/cgi-bin/WebObjects/Piano.woa/3/wo/MJejT3W9gBdgLY53L5o6g0/2.11.3">FAQs</a> --> | <a href="/cgi-bin/WebObjects/Piano.woa/3/wo/MJejT3W9gBdgLY53L5o6g0/2.11.5">Sign Out</a></div>
<div class="footerCopyright" align="center">Copyright &#169; 2008 Apple Inc. All rights reserved. </div><br/>
</snip>


Top
 Profile  
 
 Post subject: Re: Downloading Sales/Trend Reports
PostPosted: Sat Aug 30, 2008 4:49 pm 
Offline

Joined: Thu Aug 28, 2008 11:20 am
Posts: 8
here is what I used:

curl --cookie-jar cookies --cookie cookies --location-trusted -e ";auto" -d "9.6.0=12336242" -d "vndrid=12336242" -d "select1=999998.0" -d "9%2e18=" -d "SubmitBtn=Submit" "https://itts.apple.com${ACTION}" -o out.html

I used both %2e for the period in the curl line. same result. Also, I grep'd for superPage form and I get the right action back..

you see anything that I am missing?

I know your busy Rick, I appreciate your response whenever you get the chance.

thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Localized by Maël Soucaze © 2010 phpBB.fr