Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save haraldfianbakken/32d5ac624c842a766df3 to your computer and use it in GitHub Desktop.
Save haraldfianbakken/32d5ac624c842a766df3 to your computer and use it in GitHub Desktop.
$loginBase = "https://itunesconnect.apple.com";
$loginUrl = "$($loginBase)/WebObjects/iTunesConnect.woa";
# Load the login-page
$r = Invoke-WebRequest $loginUrl -SessionVariable ws;
# Set the login data
$form = $r.Forms[0];
$form.Fields["theAccountName"] = "this-is-a-test@gmail.com";
$form.Fields["theAccountPW"] = "this_is_my_password";
# Log in
$r=Invoke-WebRequest -Uri ($loginBase + $form.Action) -WebSession $ws -Method $form.Method -Body $form.Fields
# Fetch the JSON data (Scraped from the webpage)
$jsonSummaryUrl = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/manageyourapps/summary";
$response = Invoke-WebRequest $jsonSummaryUrl -WebSession $ws;
$json = $response.Content|ConvertFrom-Json
# Show me what apps I have
$json.data.summaries
<#
adamId : xxxxxxxxxxxx
name : Some name random name
vendorId : MyVendorID
bundleId : com.fianbakken.mobile.xxxxx
appType : ios
versions : {@{version=1.0.4; .... appType=ios}}
lastModifiedDate : 1422018040000
iconUrl : https://s4.mzstatic.com/us/r30/Purple6/sensored/icon340x340.png
type : ios
adamId : xxxxxxxxxxxx2
name : Some name 2
vendorId : MyVendorID2
bundleId : com.fianbakken.mobile.xxxxx2
appType : ios
versions : {@{version=3.0.4; .... appType=ios}}
lastModifiedDate : 1422018040000
iconUrl : https://s4.mzstatic.com/us/r30/Purple5/sensored/icon340x340.png
type : ios
adamId : xxxxxxxxxxxx3
name : Some name random name 3
vendorId : MyVendorID3
bundleId : com.fianbakken.mobile.xxxx3
appType : ios
versions : {@{version=4.1.4; .... appType=ios}}
lastModifiedDate : 145018040000
iconUrl : https://s4.mzstatic.com/us/r30/Purple7/sensored/icon340x340.png
type : ios
adamId : xxxxxxxxxxxx4
name : Some name random name 4
vendorId : MyVendorID4
bundleId : com.fianbakken.mobile.xxxx4
appType : ios
versions : {@{version=3.1.4; .... appType=ios}}
lastModifiedDate : 145018040000
iconUrl : https://s4.mzstatic.com/us/r30/Purple2/sensored/icon340x340.png
type : ios
#>
$appsByName=$json.data.summaries|select -ExpandProperty versions|Group-Object Name
# Show me the name, version, bundleId and the state
$appsByName.Group|Select Name, version, bundleId, state
<#
name version bundleId state
---- ------- -------- -----
Some name random name 1.0.4 com.fianbakken.mobile.xxxxx developerRemovedFromSale
Some name 2 3.0.4 com.fianbakken.mobile.xxxxx2 readyForSale
Some name random name 3 4.1.4 com.fianbakken.mobile.xxxxx3 metadataRejected
Some name random name 4 3.1.4 com.fianbakken.mobile.xxxxx4 readyForSale
#>
@djkazoo2002
Copy link

Thank you so much for sharing this. This is exactly what I wanted to retrieve the data from Itune Connect.
I have a question about this code, since I am having this error, "Cannot index into a null array."

in here

Set the login data

$form = $r.Forms[0];
$form.Fields["theAccountName"] = "this-is-a-test@gmail.com";
$form.Fields["theAccountPW"] = "this_is_my_password";

for example my username is test@yahoo.com and my password is mysecretpassword,

so just change like this

Set the login data

$form = $r.Forms[0];
$form.Fields["theAccountName"] = "test@yahoo.com";
$form.Fields["theAccountPW"] = "mysecretpassword";

and then I assume that "theAccountName" and "theAccountPW" are "theAccountName" where I can see right above the screen and "theAccountPW same as above so I did like this

Set the login data

$form = $r.Forms[0];
$form.Fields["My Name"] = "test@yahoo.com";
$form.Fields["mysecretpassword"] = "mysecretpassword";

but it still causing error, how should I change it to work
Thank you so much and Happy Holidays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment