BaseMax / GooglePlayWebServiceAPI

Tiny script to crawl information of a specific application in the Google play/store base on PHP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is the API stopped to work ?

Mnshawaty opened this issue · comments

hi i want to thank you very much for this usefull project
but today its stopped suddenly i think google play changed the api or something happen please can you update it ?

Hi Mohammad, I hope you are well.

Please add more details if you can.
Maybe we need to debug and add a few logs to find which parts of the process have problems.

Best

Dear @IzzySoft, are you aware of the changes Google Play made recently as Mohammad claim it? Thanks.

hi while i trying to to check for package id : com.whatsapp

in front end i will recicve this message
{"success":0,"message":null}

and in error log i will receive this

PHP Warning: Invalid argument supplied for foreach() in /examples.php on line 18

can you check in your side please if its work

hi while i trying to to check for package id : com.whatsapp

in front end i will recicve this message {"success":0,"message":null}

and in error log i will receive this

PHP Warning: Invalid argument supplied for foreach() in /examples.php on line 18

Thanks for adding more details, What is the line 18 of examples.php file?

this is my example file
the array return empty value i edited the code the error in the line foreach($array as $value)


<?php
header("Content-Type: application/json; charset=UTF-8");
    
$appid=$_GET["id"];
// https://github.com/BaseMax/GooglePlayWebServiceAPIp
require "google-play.php";
$google = new GooglePlay();

$app=$google->parseApplication($appid);

foreach($array as $value)
{
    $app[]=array($value["icon"]);
}
$temo = json_encode($app);
print_r($temo);
?>

hi sorry the problem from my host there is a problem between json and php
i will tell talk with host
thaNK YOU ALL

hi sorry the problem from my host there is a problem between json and php i will tell talk with host thaNK YOU ALL

That is an Iranian host/server?

commented

are you aware of the changes Google Play made recently as Mohammad claim it?

No. And though I use the API at least once or twice a week, I had no need the last 3 days. But let me give it a try… Nope, I cannot confirm any issue. Just tried it with com.whatsapp and got the full list of permissions, and also the full application data were retrieved fine. Might be a server issue.

If examples.php means the one we ship, that'd be a call to parseTopApps(). Those I rarely use (the only things I use regularly is application data and permissions). Just tried that now, and I get a list of 68 apps – so again, I can see no issue. But then, that has no foreach either.

But I found the issue – just not on our end. Take a look at the code @Mnshawaty quoted, especially this section:

$app=$google->parseApplication($appid);

foreach($array as $value)
{
    $app[]=array($value["icon"]);
}

Now tell me what value is assigned to $array there? Hint: It was never initialized. Hint 2: as it is most likely the result of the call to parseApplication() which should be parsed, that should be $app. But then the $app[] = in the loop would break it – apart from the fact that there is no $value["icon"], as the icon is $app["icon"] – no foreach needed at all.

@Mnshawaty not sure what you want to achieve there, but you should check your variables and their assignments 😉

Thanks Izzy for the comments.

Izzy well said, As a new PHP developer that use PHP only for 10 years I have nothing to add. but I like to add a new Hint.

Your code:

foreach($array as $value)
{
    $app[]=array($value["icon"]);
}

Not related to this project, but I think it's better to use the array_column function to get icon values.

for example:

<?php
$items = [
	[
		"id" => 1,
		"icon" => "icon1",
	],
	[
		"id" => 2,
		"icon" => "icon2",
	],
	[
		"id" => 3,
		"icon" => "icon3",
	],
	[
		"id" => 4,
		"icon" => "icon4",
	],
	[
		"id" => 5,
		"icon" => "icon5",
	],
];

$icons = array_column($items, "icon");
print_r($icons);

Best Wishes

Just adding another important note. You must to check $_GET and $_POST values are exists before using it.

$appid=$_GET["id"];

Before that, you need to make sure id is available or not.
So It can be something like:

<?php
if (!isset($_GET["id"])) exit();
$app_id = $_get["id"];

// TODO

Cheers

commented

As this fell silent, I assume your problem is solved, @Mnshawaty – so this issue can be closed?

Agree, I think so.

Hi guys thank you very much the problem solved it was because
allow_url_fopen disabled from the host

Now its fine thank you all ❤️

Happy to help. Best wishes @Mnshawaty