本文实例讲述了PHP实现自动登入google play下载app report的方法,有不错的实用价值。分享给大家供大家参考。具体实现步骤如下:
一、流程:
1.登入google play
登入google play需要三步:
https://play.google.com/apps/publish/
https://accounts.google.com/ServiceLogin"htmlcode">
<"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, $this->password); // download report zip return $this->downloadReport($package, $sd, $ed, $dim, $met, $this->dev_acc, $downloadFile); } /* login google play,create cookies * @param String $username * @param String $password * @return boolean */ private function loginAuth($username, $password){ // step1 $mainUrl = "https://play.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".$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 Report zip file private function downloadReport($package, $sd, $ed, $dim, $met, $dev_acc, $downloadFile) { $url = "https://play.google.com/apps/publish/statistics/download"; $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 report * @param String $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, $downloadFile); } ?>
相信本文所述对大家的PHP程序设计有一定的借鉴价值。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月16日
2024年11月16日
- 方伊琪.1979-沙鸥(LP版)【星岛全音】【WAV+CUE】
- 蔡琴《醇厚嗓音》6N纯银SQCD【WAV+CUE】
- 陈曦《遇见HQCD》[WAV+CUE]
- 大提琴-刘欣欣《爱的问候》HDCD[WAV+CUE]
- 周耀辉/邓慧中《从什么时候开始》[320K/MP3][95.71MB]
- 周耀辉/邓慧中《从什么时候开始》[FLAC/分轨][361.29MB]
- 蒋荣宗《蒋荣宗ZONG x FOCA 夏日马戏节》[320K/MP3][89.28MB]
- 坣娜.1997-你怎么可以不爱我【巨石】【WAV+CUE】
- 群星.1992-暗恋桃花源电影原声带【滚石】【WAV+CUE】
- 林隆璇.1989-愤怒的情歌【巨石】【WAV+CUE】
- 勤琴《海上花》[DTS-WAV分轨]
- 群星《歌声有故事》[DTS-WAV分轨]
- [发烧人声]群星《邂逅》DTS-WAV
- 艻打绿《夏/狂热(苏打绿版)》[320K/MP3][106.42MB]
- 艻打绿《夏/狂热(苏打绿版)》[FLAC分轨][574.2MB]