How to automatically log into Google Play download app

Source: Internet
Author: User
Tags continue log php define zip

Process

1. Login to Google Play

It takes three steps to log into Google Play

https://play.google.com/apps/publish/

https://accounts.google.com/ServiceLogin?hl=en&continue=https://play.google.com/apps/publish/

Https://accounts.google.com/ServiceLoginAuth

2. Download App zip

3.unzip

The code is as follows:

<?php define (' Root_path ', DirName (__file__));  
      
Define (' Google_play_cookie_file ', ' google_play_cookie.txt '); /** * Login Google Play, download, unzip * DATE:2013-04-17 * Author:fdipzone * version:1.0/class  
    androidreportdownloader{private $username;  
    Private $password;  
      
      
    Private $dev _ACC; /* init * @param string $username Google Play account * @param string $password the Google Play password * @p Aram String $dev _acc Google Play dev account/Public function __construct ($username = ', $password = ', $dev _ac  
        C= ') {$this->username = $username;  
        $this->password = $password;  
    $this-&GT;DEV_ACC = $dev _acc; /* * @param string $appname * @param string $sd Start date * @param string $e D End Date * @param String $downloadFile saved zip name */Public Function run ($appname = ', $sd = ', $ed = ' ',$downloadFile = ') {$package = $appname;  
        $dim = ' overall,country,language,os_version,device,app_version,carrier '; $met = ' Daily_device_installs,active_device_installs,daily_user_installs,total_user_installs,active_user_  
        Installs,daily_device_uninstalls,daily_user_uninstalls,daily_device_upgrades '; $met = "Daily_device_installs,current_device_installs,daily_user_installs,total_user_installs,current_user_ Installs,daily_device_uninstalls,daily_user_uninstalls,daily_device_upgrades "; Google Modify 2013-08-06//login Google Play $this->loginauth ($this->username, $t  
      
        His->password); Download $this->downloadreport ($package, $SD, $ed, $dim, $met, $this->dev_acc, $DOWNL  
          
    Oadfile);  
    }/* Login Google play,create cookies * @param string $username * @param string $password * @return Boolean * *
    Private Function Loginauth ($username, $password) {//Step1 $MAINURL = "Https://pla  
      
        y.google.com/apps/publish/";  
        $ch = Curl_init ();  
        curl_setopt ($ch, Curlopt_url, $MAINURL);  
        curl_setopt ($ch, Curlopt_cookiejar, google_play_cookie_file);   
        curl_setopt ($ch, Curlopt_cookiefile, google_play_cookie_file);  
        curl_setopt ($ch, Curlopt_returntransfer, 1);  
        Curl_exec ($ch);  
      
        Curl_close ($ch);  
        Step 2 $serviceLoginUrl = "https://accounts.google.com/ServiceLogin?hl=en&continue=". $mainUrl;  
        $ch = Curl_init ();  
        curl_setopt ($ch, Curlopt_url, $SERVICELOGINURL);  
        curl_setopt ($ch, Curlopt_cookiejar, google_play_cookie_file);   
        curl_setopt ($ch, Curlopt_cookiefile, google_play_cookie_file);  
        curl_setopt ($ch, Curlopt_returntransfer, 1);  
        $serviceLoginRespHtml = curl_exec ($ch);  
      
    Curl_close ($ch);    Preg_match ('/name= "DSH" \s*id= "DSH" \s*value= "(. *?)" \s*/i ', $serviceLoginRespHtml, $matches);  
      
        Get dsh $dsh = $matches [1]; Preg_match ('/name= "Galx" \s*value= "(. *?)" \s*/i ', $serviceLoginRespHtml, $matches);  
      
        Get galx $galx = $matches [1];  
        Step 3 $loginGoogleUrl = "Https://accounts.google.com/ServiceLoginAuth";  
        $postFields = "referer=". $serviceLoginUrl;  
        $postFields. = "&allowautoredirect=false";  
        $postFields. = "&continue=". $mainUrl;  
        $postFields. = "&dsh=". $dsh;  
        $postFields. = "&h1=en";  
        $postFields. = "&galx=". $galx;  
        $postFields. = "&email=". $username;  
        $postFields. = "&passwd=". $password;  
        $postFields. = "&signin=sign+in";  
              
        $postFields. = "&persistentcookie=yes";  
        $ch = Curl_init ();  
        curl_setopt ($ch, Curlopt_url, $LOGINGOOGLEURL); curl_setopt ($ch, CUrlopt_post, 1);  
        curl_setopt ($ch, Curlopt_postfields, $postFields);  
        curl_setopt ($ch, Curlopt_cookiejar, google_play_cookie_file);   
        curl_setopt ($ch, Curlopt_cookiefile, google_play_cookie_file);   
        curl_setopt ($ch, Curlopt_header, true);   
        curl_setopt ($ch, curlopt_followlocation, true);  
        curl_setopt ($ch, Curlopt_returntransfer, 1);  
        Curl_exec ($ch);  
      
        Curl_close ($ch);  
          
    Login Cookies Create success return true; }///Download the downloadreport of the zip file Private function ($package, $SD, $ed, $dim, $met, $d EV_ACC, $downloadFile) {$url = "https://play.google.com/apps/publish/statistics/download?package={$packa  
              
        ge}&sd={$sd}&ed={$ed}&dim={$dim}&met={$met}&dev_acc={$dev _ACC} ";  
      
        $fp = fopen ($downloadFile, "w");   
        $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url);  
        curl_setopt ($ch, Curlopt_returntransfer, 1);  
        curl_setopt ($ch, Curlopt_file, $fp);   
        curl_setopt ($ch, Curlopt_cookiefile, google_play_cookie_file);   
        Curl_exec ($ch);   
        Curl_close ($ch);  
      
        Fclose ($FP);  
        if (file_exists ($downloadFile)) {return true;  
      
    return false;  
    }/* Unzip * @param string $path unzipped path * @param string $downloadFile zip file  
        * * Public Function Unzipreport ($path, $downloadFile) {$exec = "unzip". $downloadFile. "-D". $path;  
        Shell_exec ($exec);  Unlink ($downloadFile);  
Delete zip file}//Demo $username = ' testdev@gmail.com ';  
$password = ' abcd1234 ';  
      
$dev _ACC = ' 12345678901234567890 ';  
$appname = ' Com.testdev ';  
$SD = ' 20130417 ';  
$ed = ' 20130417 ';  
$downloadFile = ' Testdev.zip '; $unzipPath = Root_path. ' /testdev/';  
$obj = new Androidreportdownloader ($username, $password, $dev _ACC);  
if ($obj->run ($appname, $SD, $ed, $downloadFile)) {$obj->unzipreport ($unzipPath); }?>

Author: csdn blog proud Snow star Maple

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.