简体   繁体   English

如何以编程方式获取自己的Android应用统计数据?

[英]How to get own Android app statistics programmatically?

Is it possible to get programmatically app installs count from Google Play Developer Console for my own app? 是否可以通过Google Play开发者控制台为我自己的应用程序以编程方式获取应用安装数量?

Of course, it is possible to perform an attempt to login programmatically and the make some web request, that will return json with statistics that is used on the site itself to display stats, but this doesn't seem reliable for me. 当然,可以尝试以编程方式登录并发出一些Web请求,这将返回json,其中包含在站点本身使用的统计信息以显示统计信息,但这对我来说似乎不可靠。

I have found a https://code.google.com/p/androidappstats/ , but it seems to be a little outdated. 我找到了https://code.google.com/p/androidappstats/ ,但它似乎有点过时了。

Take a look at the Andlytics project on GitHub. 看看GitHub上的Andlytics项目。 It is an Open Source applications also available on Google Play. 它也是Google Play上提供的开源应用程序。 You will find a link to that on the GitHub page linked. 您将在链接的GitHub页面上找到指向该链接的链接。

However, it is not ( currently ) for one specific application on the Google Play store. 但是,它( 目前 )不适用于Google Play商店中的特定应用程序。 But rather, connects with your Developer Account and gets information about every application published using the same. 而是与您的开发者帐户连接,并获取有关使用该帐户发布的每个应用程序的信息。

That being said, since it is Open Source, I am sure it can be tweaked to suit your exact purpose. 话虽如此,因为它是开源的,我相信它可以调整,以满足您的确切目的。

There is also an unofficial API of sorts here: https://code.google.com/p/android-market-api/ . 此处还有一个非官方的API: https//code.google.com/p/android-market-api/ But a quick look at the source suggests that this is not updated anymore / regularly. 但是快速浏览一下消息来源表明这不会再次/定期更新。

Andlytics is on the other hand, is regularly updated (to accommodate any changes made to the Google Play store). 另一方面,Andlytics会定期更新(以适应对Google Play商店所做的任何更改)。

有一个非官方的图书馆,可以在https://code.google.com/p/android-market-api/找到

Well, I have chosen the following solution. 好吧,我选择了以下解决方案。 As I am a .NET programmer, it is not easy for me to use Java libraries, and I do not have both enough time and will to rewrite them to C#. 因为我是.NET程序员,所以使用Java库并不容易,而且我没有足够的时间和意愿将它们重写为C#。

In Steven Sanderson's blog I have found an article on headless browser automation ( http://blog.stevensanderson.com/2010/03/30/using-htmlunit-on-net-for-headless-browser-automation/ ) 在Steven Sanderson的博客中,我发现了一篇关于无头浏览器自动化的文章( http://blog.stevensanderson.com/2010/03/30/using-htmlunit-on-net-for-headless-browser-automation/

Here is the code I wrote: 这是我写的代码:

WebClient _webClient = new WebClient( BrowserVersion.FIREFOX_17 );
_webClient.getOptions().setUseInsecureSSL( true );
_webClient.getOptions().setThrowExceptionOnScriptError( false );
_webClient.getOptions().setRedirectEnabled( true );

var page = (HtmlPage)_webClient.getPage( "https://play.google.com/apps/publish/v2/" );

HtmlInput emailElement = (HtmlTextInput)page.getElementById( "Email" );
emailElement.type( Settings.Default.Login );

HtmlInput passwordElement = (HtmlInput)page.getElementById( "Passwd" );
passwordElement.type( Settings.Default.Password );

HtmlSubmitInput signInLink = (HtmlSubmitInput)page.getElementById( "signIn" );
HtmlPage page2 = (HtmlPage)signInLink.click();

_webClient.waitForBackgroundJavaScript( 2000 );

var installsNode = ( from p in page2.getElementsByTagName( "p" ).toArray().Cast<HtmlParagraph>()
                     let data_column = p.getAttribute( "data-column" )
             where data_column != null && "INSTALLS".Equals( data_column, StringComparison.OrdinalIgnoreCase )
             select p ).FirstOrDefault();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM