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.
// specify the repo URL below:
$repo="http://aptoide.com/repo/";
$repodir=$repo; // we need it later as the basepath// Then, by using simplexml_load_file() function, we fetch the info.xml.
$repo=$repo."info.xml";
$xml = simplexml_load_file($repo);
$tracks = $xml->package;//now we have all the value in one array variable, $tracks
// now we will extract the values$number = 50;
// that was estimation number of the apk listed inside the info.xml,
//I use 5000 for a big repofor ($i = 0; $i < $number; $i++) {
$package = $tracks[$i];// the name of the apps
$name = $package->name;
// the path
$url = $package->path;
// this is the full path
$url=$repodir.$url;
// apk version
$ver = $package->ver;
// prevent if the version is empty
if($ver!=""){$ver="$ver";} else {$ver="Unknown";}
// date of apk insertion to the xml
$date = $package->date;
if($date!=""){$date="$date";} else {$date=date("Y-m-d");}
// the package’s icon
$img = $package->icon;
if($img!=""){$img=$repodir.$img;}
// package ID, we need it, trust me.. 😀
// (I use it in andiim3.com for details fetching)
$id = $package->apkid;
if($id==""){$id="Unknown";}// now you can output the package details as you want..
// output in table format is the best, but you may try different method
echo “<img src=’$img’ style=’float:left;’ width=’48’ />â€;
echo “Name : $name <br/>â€;
echo “Version : $ver <br/>â€;
echo “Date : $date<br/>â€;
echo “APK ID : $apkid <br/>â€;
echo “<a href=’$url’>Download</a> <br/><br/>â€;}
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
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.
Dobby and Luna have been part of our lives for the past years. They have…
In the year 2021, I've completed some paid projects. Some of them are more technical,…
Based on the GlassTime Bootstrap template, here I present glassmorphism WordPress Theme free to download.This…
This HTML5 template is using Glassmorphism UI design language which is now trending for 2021…
KecamatanKode POSBanjar81152Buleleng81119Busungbiu81154Gerokgak81155Kubutambahan81172Sawan81171Seririt81153Sukasada81161Tejakula81173Klik pada nama kecamatan untuk melihat daftar desa masing-masing. Sumber: kodepos.andiim3.com
Ada yang bilang "semuanya akan mati matic pada akhirnya". Bener aja, sekarang tuntutan transportasi sehari-hari…
This website uses cookies.