Now we will learn how to fetch values from android repository with PHP, and display it on your page. (See andiim3.com for example).
Usually, android user will use aptoide, APKtor, etc. to browse outside repo beside Google’s Android Market. But, there a lot of user prefer to download the apps from PC browser instead of their mobile.
We need to know that every android repo provide us a XML file to read. Named info.xml, it contains all the information needed by the client. So, we will fetch the info.xml.
I will explain the steps inline with the code. Remember, this is the basic script I use in alpha version of my website (andiim3.com). andiim3.com now use more advanced way to fetch the repos, but the basic method still included.
That’s it.. You may use this script in your own website. But I warn you, this method can waste your web hosting bandwidth if you don’t have an unlimited hosting plan.
As usually, I will give you the algorithm of my advanced script used in andiim3.com
- To save the bandwidth, we fetch the info.xml once a day, we use cron in cpanel
- In fetching process: first, we truncate the database before inserting new data to prevent duplicate rows. Then we insert all the new apk data back to the database.
- We don’t output the apk data in the cron job, it is unnecessary. We use another script to display the database to the audience. I think it’s quite easy to fetch the rows from database and display it on your pages. Code it yourself!
The advantages of using database is to save your bandwidth, saves times (no need to fetch all the repos first for one only request), we can do easy APK searching, we can short it, we can track the statistic, etc.