From 14543f624e055a8d5c206490b801087b57fc6b8d Mon Sep 17 00:00:00 2001 From: Izzy Date: Sat, 8 Apr 2023 22:33:18 +0200 Subject: [PATCH 1/4] add debug method (dump_raw) to dump internal data / page structures --- google-play.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/google-play.php b/google-play.php index be5c925..c88375c 100644 --- a/google-play.php +++ b/google-play.php @@ -59,6 +59,26 @@ protected function getApplicationPage($packageName, $lang='en_US', $loc='US') { } } + /** Dump the raw page content for debugging purposes + * @method dump_raw + * @param string packageName identifier for the app, e.g. 'com.example.app' + * @param optional string fileName basename of the files to write to, optionally with leading path (default: ${packageName}; extensions will be appended) + * @param optional string lang language for translations. Should be ISO 639-1 two-letter code. Default: en + * @param optional string loc locale, mainly for currency. Again two-letter, but uppercase + * @return bool success + */ + public function dump_raw($packageName, $fileName='', $lang='en_US', $loc='US') { + if ( empty($this->input) ) $this->getApplicationPage($packageName, $lang='en_US', $loc='US'); + if ( empty($fileName) ) $fileName = $packageName; + file_put_contents("${fileName}.txt", $this->input); + // also dump the protos + for ($i=1;$i<10;++$i) { + if ( $proto = json_decode( $this->getRegVal("/key: 'ds:${i}'. hash: '\d+'. data:(?\[\[\[.+?). sideChannel: .*?\);<\/script/ims") ) ) { + file_put_contents("${fileName}_ds${i}.json", json_encode($proto, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); + } + } + } + /** Obtain app version details * @method public parseVersion * @param string packageName identifier for the app, e.g. 'com.example.app' From dd801e59bf6cb1a66041d3069bbe1883ab74d444 Mon Sep 17 00:00:00 2001 From: Izzy Date: Sun, 9 Apr 2023 01:32:00 +0200 Subject: [PATCH 2/4] also include DS:0 (categories of this app) with dump_raw() --- google-play.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-play.php b/google-play.php index c88375c..7a5236b 100644 --- a/google-play.php +++ b/google-play.php @@ -72,7 +72,7 @@ public function dump_raw($packageName, $fileName='', $lang='en_US', $loc='US') { if ( empty($fileName) ) $fileName = $packageName; file_put_contents("${fileName}.txt", $this->input); // also dump the protos - for ($i=1;$i<10;++$i) { + for ($i=0;$i<10;++$i) { if ( $proto = json_decode( $this->getRegVal("/key: 'ds:${i}'. hash: '\d+'. data:(?\[\[\[.+?). sideChannel: .*?\);<\/script/ims") ) ) { file_put_contents("${fileName}_ds${i}.json", json_encode($proto, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); } From dc5a975947c9bea0675a10943d49c080a9dea38f Mon Sep 17 00:00:00 2001 From: Izzy Date: Sun, 9 Apr 2023 01:45:41 +0200 Subject: [PATCH 3/4] dump_raw: change extension for page dump to .html --- google-play.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-play.php b/google-play.php index 7a5236b..65bca91 100644 --- a/google-play.php +++ b/google-play.php @@ -70,7 +70,7 @@ protected function getApplicationPage($packageName, $lang='en_US', $loc='US') { public function dump_raw($packageName, $fileName='', $lang='en_US', $loc='US') { if ( empty($this->input) ) $this->getApplicationPage($packageName, $lang='en_US', $loc='US'); if ( empty($fileName) ) $fileName = $packageName; - file_put_contents("${fileName}.txt", $this->input); + file_put_contents("${fileName}.html", $this->input); // also dump the protos for ($i=0;$i<10;++$i) { if ( $proto = json_decode( $this->getRegVal("/key: 'ds:${i}'. hash: '\d+'. data:(?\[\[\[.+?). sideChannel: .*?\);<\/script/ims") ) ) { From d700d4f22f808de629fc40828f31a76ce596db5a Mon Sep 17 00:00:00 2001 From: Izzy Date: Sun, 9 Apr 2023 02:06:47 +0200 Subject: [PATCH 4/4] fix dump_raw for ds:3 (slightly different format) --- google-play.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/google-play.php b/google-play.php index 65bca91..5fc150d 100644 --- a/google-play.php +++ b/google-play.php @@ -75,6 +75,8 @@ public function dump_raw($packageName, $fileName='', $lang='en_US', $loc='US') { for ($i=0;$i<10;++$i) { if ( $proto = json_decode( $this->getRegVal("/key: 'ds:${i}'. hash: '\d+'. data:(?\[\[\[.+?). sideChannel: .*?\);<\/script/ims") ) ) { file_put_contents("${fileName}_ds${i}.json", json_encode($proto, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); + } elseif ( $proto = json_decode( $this->getRegVal("/key: 'ds:${i}'. hash: '\d+'. data:(?\[\[.+?). sideChannel: .*?\);<\/script/ims") ) ) { // ds:3 + file_put_contents("${fileName}_ds${i}.json", json_encode($proto, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); } } }