PHP Classes

PHP APK File Download Collector: Download Android app files from various sites

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 185 This week: 1All time: 8,645 This week: 560Up
Version License PHP version Categories
apk_collector 1.0.0MIT/X Consortium ...5PHP 5, Wireless and Mobile, Files and...
Description 

Author

This package can download Android app files from various sites.

It provides a console based in interface to let the user select a download site from where he can download APK files that are from applications that can be installed in Android devices.

The package can download APK files from the selected site and store them in a local directory so they can be installed in an android device without downloading them again.

Innovation Award
PHP Programming Innovation award nominee
August 2019
Number 3
APK is a file format used by Android applications to install them on mobile devices that run the Android operating system.

This package makes it easier to download APK files of many kinds of Android applications from various sites.

Manuel Lemos
Picture of Chun-Sheng, Li
  Performance   Level  
Name: Chun-Sheng, Li <contact>
Classes: 27 packages by
Country: Taiwan Taiwan
Age: 30
All time rank: 22646 in Taiwan Taiwan
Week rank: 416 Up1 in Taiwan Taiwan Up
Innovation award
Innovation award
Nominee: 13x

Winner: 1x

Example

<?php
    set_time_limit
(0);
   
ini_set("allow_url_fopen", "On");
    require
"vendor/autoload.php";
    require
"helper/greet.php";
    require
"helper/parser.php";
    require
"helper/fix_download.php";

    use
GuzzleHttp\Client;
    use
Psr\Http\Message\ResponseInterface;
    use
GuzzleHttp\Exception\RequestException;
   
    use
Symfony\Component\Console\Command\Command;
    use
Symfony\Component\Console\Input\InputArgument;
    use
Symfony\Component\Console\Input\InputInterface;
    use
Symfony\Component\Console\Input\InputOption;
    use
Symfony\Component\Console\Output\OutputInterface;
    use
Symfony\Component\Console\Application;
    use
Symfony\Component\Console\Question\ChoiceQuestion;
   
    class
download_command extends Command {
        private
$urls = array(
           
'http://www.apkmirror.com', 'http://www.androidapksfree.com/', 'fixing error when downloading apk'
       
);
       
        protected function
configure() {
           
$this
               
-> setName('download')
                ->
setDescription('what kinds of file (default: apk)?')
                ->
addArgument(
                   
'action',
                   
InputArgument::OPTIONAL);
        }
       
        protected function
execute(InputInterface $input, OutputInterface $output) {
           
           
$action = $input->getArgument('action');
           
            if(
$action == "apk" || $action == "") {
               
$helper = $this -> getHelper('question');
               
$question = new ChoiceQuestion('Please select the url that you want to download (the default url is http://www.apkmirror.com)',
                   
$this -> urls, 0);
               
               
$question -> setErrorMessage('The apk url %s is invalid.');
               
               
$url = $helper -> ask($input, $output, $question);
               
               
$output -> writeln('You selected: ' . $url);
               
                if(
$url != "fixing error when downloading apk")
                    echo
$this -> request_initial($url, $output);
                else
                   
fix_download_apk();
            }
        }
       
        private function
request_initial($url, $output) {
           
$urls = $this -> urls;
           
$pages = 0;

           
$client = new Client();
   
            try {
       
               
$response = $client -> get($url);
               
                if(
$response -> getStatuscode() == 200) {
                   
$dir_path = "";
                   
                    switch(
$url) {
                        case
$urls[0]:
                           
$pages = get_apkmirror_pages($response -> getBody() -> getContents());
                           
$dir_path = "./helper/files/apkmirror";
                            break;
                        case
$urls[1]:
                           
$pages = androidapks_free_pages($response -> getBody() -> getContents());
                           
$dir_path = "./helper/files/androidapksfree";
                            break;
                        case
$urls[2]:
                           
fix_download_apk();
                            break;
                    }
                   
                    @
mkdir($dir_path);
                }
                else {
                    die(
$output -> writeln($response -> getBody() -> getContents()));
                }
            }
            catch(
Exception $e) {
                die(
$output -> writeln($e -> getMessage()));
            }
   
           
/*
            * Firstly, run page 1
            * and some applications have downloaded successfully.
            * e.g. Changing the page 1 to page 122. (up to the situation.)
            */
           
           
$page = 1;
            if(
file_exists("./curr_page.txt")) {
               
$curr_page = file_get_contents("./curr_page.txt");
               
$page = $curr_page;
            }
           
            for(;
$page<=$pages;$page++) {
               
//record the current page
               
file_put_contents("./curr_page.txt", $page);
                try {
                   
$response = $client -> get($url . "/page/" . $page . "/");
                }
                catch(
Exception $e) {
                    die(
$output -> writeln($e -> getMessage()));
                }
               
                switch(
$url) {
                    case
$urls[0]:
                       
parse_apkmirror_html($url, $response -> getBody() -> getContents());
                        break;
                    case
$urls[1]:
                       
androidapks_free_html($url, $response -> getBody() -> getContents());
                        break;
                }
            }
        }
    }
   
   
$command = new greet();
   
$application = new Application('apk_collector', 'beta-1.0');
   
$application -> add($command);
   
$application -> add(new download_command());
   
$application -> setDefaultCommand($command -> getName());
   
$application -> run();

?>


Details

apk_collector

Provide more apk files from various sites

Introduction

This project will provide you lots of apk files and it will automatically dowload files from various sites.

Usage

+ If you just want to collect many apk files to do something, you can download the phar file that is a [release]() version. + If you want to build your own collector or specify the url, you have to clone this project and modify the `url.json` and `index.php`. After editing `url.json`, you can just run the command: `php index.php` then done.

License

MIT


  Files folder image Files  
File Role Description
Files folder imagehelper (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Start script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  helper  
File Role Description
  Accessible without login Plain text file fix_download.php Example Example script
  Plain text file greet.php Class Class source
  Accessible without login Plain text file parser.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:185
This week:1
All time:8,645
This week:560Up