From 5a07c858eac523d6fa30541e7de0d03c405a2b93 Mon Sep 17 00:00:00 2001 From: Izzy Date: Fri, 4 Dec 2020 19:27:37 +0100 Subject: [PATCH 1/2] capture 404 error --- google-play.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google-play.php b/google-play.php index 79c6ca3..b6f38db 100644 --- a/google-play.php +++ b/google-play.php @@ -71,7 +71,9 @@ class GooglePlay { ]; public function parseApplication($packageName) { $link="https://play.google.com/store/apps/details?id=".$packageName."&hl=en_US&gl=US"; - $input=file_get_contents($link); + if ( ! $input = @file_get_contents($link) ) { + return []; + } // file_put_contents("t.html", $input); $values=[]; $values["packageName"]=$packageName; From df9bb9530420357f20a707a92ba3ab3821f424b3 Mon Sep 17 00:00:00 2001 From: Izzy Date: Fri, 4 Dec 2020 19:40:51 +0100 Subject: [PATCH 2/2] improve error handling --- google-play.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/google-play.php b/google-play.php index b6f38db..52fc633 100644 --- a/google-play.php +++ b/google-play.php @@ -72,7 +72,7 @@ class GooglePlay { public function parseApplication($packageName) { $link="https://play.google.com/store/apps/details?id=".$packageName."&hl=en_US&gl=US"; if ( ! $input = @file_get_contents($link) ) { - return []; + return ['success'=>0,'message'=>'Google returned: '.$http_response_header[0]]; } // file_put_contents("t.html", $input); $values=[]; @@ -84,7 +84,7 @@ public function parseApplication($packageName) { $values["name"]=trim(strip_tags($name["content"])); } else { - return []; + return ['success'=>0,'message'=>'No app data found']; return $values; $values["name"]=null; } @@ -191,6 +191,7 @@ public function parseApplication($packageName) { if($this->debug) { print_r($values); } + $values['success'] = 1; return $values; }