简体   繁体   中英

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?

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.

I have found a https://code.google.com/p/androidappstats/ , but it seems to be a little outdated.

Take a look at the Andlytics project on GitHub. It is an Open Source applications also available on Google Play. You will find a link to that on the GitHub page linked.

However, it is not ( currently ) for one specific application on the Google Play store. 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/ . 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).

有一个非官方的图书馆,可以在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#.

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/ )

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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