4 * List all package names from a reg_server_response.json that are "popular"
7 fwrite(STDERR, "reg_server_response.json file missing\n");
12 if (!file_exists($regFile)) {
13 fwrite(STDERR, "json file does not exist: $regFile\n");
16 if (!is_readable($regFile)) {
17 fwrite(STDERR, "Cannot read json file: $regFile\n");
21 $regData = json_decode(file_get_contents($regFile));
22 if ($regData === null) {
23 fwrite(STDERR, "Cannot parse JSON data\n");
24 fwrite(STDERR, json_last_error_msg() . "\n");
28 if (!isset($regData->body->config->apps)) {
29 fwrite(STDERR, "File contains no apps\n");
34 foreach ($regData->body->config->apps as $app) {
35 if ($app->popular > 0) {
36 $popular[$app->package] = $app->popular;
41 echo implode("\n", array_flip($popular)) . "\n";