PostcodesIO adalah perpustakaan PHP untuk postcodes.io API.
Instal menggunakan komposer:
$ composer require jabranr/postcodes-io
Semua metode berikut mengembalikan respons lengkap yang sama seperti yang berasal dari postcodes.io API dalam format JSON.
Prasyarat
Buruh pelabuhan
Mulai wadah: docker-compose up
Jalankan pengujian: docker-compose exec postcodes_io bash -c "composer test"
Debugging Xdebug sudah diinstal dan diaktifkan sebagai bagian dari pengaturan buruh pelabuhan. Proyek ini menyertakan file pengaturan debug launch.json
untuk VSCode.
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
try {
$ addresses = $ postcodesIO -> find ( ' NW1 5LD ' );
} catch ( Exception $ e ) {
echo $ e -> getMessage ();
}
Anda dapat menangkap
JabranrPostcodesIOExceptionPostcodeIOException
tertentu atau/dan menangkapException
umum untuk menangkap jenis apa pun.
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ( ' NW1 5LD ' );
$ addresses = $ postcodesIO -> getResult ();
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> findByLocation ( 51.520331 , - 0.1396267 );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> findRandom ();
ATAU gunakan metode alias:
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> random ();
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> validate ( ' NW1 5LD ' );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> findNearest ( ' NW1 5LD ' );
ATAU gunakan metode alias:
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> nearest ();
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> autocomplete ( ' NW1 ' );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> query ( ' NW1 5LD ' );
ATAU gunakan metode alias:
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> search ( ' NW1 5LD ' );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> findOutcode ( ' NW1 ' );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> nearestOutcode ( ' NW1 ' );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> findOutcodeByLocation ( 51.520331 , - 0.1396267 );
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> bulkPostcodeSearch ( array ( ' NW1 5LD ' , ' W1T 7NY ' ));
Maksimum 100 kode pos per permintaan.
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> bulkReverseGeocoding ( array (
array ( 51.520331 , - 0.1396267 ),
array ( 51.520331 , - 0.1396267 )
));
atau
use Jabranr PostcodesIO PostcodesIO ;
$ postcodesIO = new PostcodesIO ();
$ addresses = $ postcodesIO -> bulkReverseGeocoding ( array (
array ( ' latitude ' => 51.520331 , ' longitude ' => - 0.1396267 ),
array ( ' latitude ' => 51.520331 , ' longitude ' => - 0.1396267 )
));
Maksimal 100 geolokasi per permintaan.
Lisensi MIT © 2016 – sekarang | Jabran Rafik