|
|
1 |
|
|
|
2 |
|
|
|
3 |
MaxMindWebServices Class
|
|
|
4 |
========================
|
|
|
5 |
|
|
|
6 |
The MaxMindWebServices class is an abstract class that all MaxMind web services extend from. This class has no public access.
|
|
|
7 |
|
|
|
8 |
I have made a few assumptions in terms of the other services since I have yet to use them.
|
|
|
9 |
|
|
|
10 |
1. I assume that all services would have a need to look up:
|
|
|
11 |
a. Country Codes
|
|
|
12 |
b. SubCountry Codes
|
|
|
13 |
c. Metro Codes
|
|
|
14 |
|
|
|
15 |
As a result of this assumption I have public methods for translation of these codes in the MaxMindWebServices abstraction class.
|
|
|
16 |
|
|
|
17 |
2. Since it appears that not all the Web Services have the same interface I have stored the helper functions in the abstraction class anyway. Reason for this is to reduce code between multiple services.
|
|
|
18 |
|
|
|
19 |
Methods that all MaxMind Services have:
|
|
|
20 |
setLicenceKey($key)
|
|
|
21 |
isError() // return bool
|
|
|
22 |
getResultArray() // returns all returned values in an array
|
|
|
23 |
lookupCountryCode($countryCode);
|
|
|
24 |
lookupSubCountryCode($subcountryCode, $countryCode);
|
|
|
25 |
lookupMetroCode($metroCode);
|
|
|
26 |
|
|
|
27 |
Notes:
|
|
|
28 |
|
|
|
29 |
1. the lookup...Code() methods use lazy load, they don't parse the ini file unless the method is explicitly call.
|
|
|
30 |
|
|
|
31 |
2. It is possible to set your licenceKey inside this class which then applies it as the default key for all MaxMind web services.
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
GeoCityLocateIspOrg
|
|
|
36 |
===================
|
|
|
37 |
|
|
|
38 |
This class Implements the Geo city location with ISP and Organization inforation included. This class is designed to be used as a singleton.
|
|
|
39 |
|
|
|
40 |
ex.
|
|
|
41 |
Instead of $service = new GeoCityLocateIspOrg();
|
|
|
42 |
|
|
|
43 |
use: $service = GeoCityLocateIspOrg::getInstance();
|
|
|
44 |
|
|
|
45 |
Methods:
|
|
|
46 |
setIP($ip) // this is the trigger, all data is cleared and updated with new value
|
|
|
47 |
getIP()
|
|
|
48 |
getCountry()
|
|
|
49 |
getRegion()
|
|
|
50 |
getState() // alias of getRegion()
|
|
|
51 |
getCity()
|
|
|
52 |
getPostal()
|
|
|
53 |
getZip() // alias of getPostal()
|
|
|
54 |
getLatitude()
|
|
|
55 |
getLat() // alias of getLat()
|
|
|
56 |
getLongitude()
|
|
|
57 |
getLong() // alias of getLong()
|
|
|
58 |
getMetroCode()
|
|
|
59 |
getAreaCode()
|
|
|
60 |
getISP()
|
|
|
61 |
getOrganization()
|
|
|
62 |
getError()
|
|
|
63 |
|
|
|
64 |
And all generic methods listed above.
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
For Developers
|
|
|
68 |
==============
|
|
|
69 |
|
|
|
70 |
When adding a new Web Service to this library there are a few code interface details to remember.
|
|
|
71 |
|
|
|
72 |
1. All new interfaces must extend MaxMindWebServices
|
|
|
73 |
2. All services are responsible for building the url with the query string
|
|
|
74 |
3. All services must implement a getError() method
|
|
|
75 |
4. All methods must implement there own trigger to submit and recieve data
|
|
|
76 |
5. All data recieved must be stored in $this->data array, it doesn't matter if its an assoc array or not.
|
|
|
77 |
|
|
|
78 |
TODO
|
|
|
79 |
=========
|
|
|
80 |
|
|
|
81 |
1. change the _queryMaxMind() in the MaxMindWebService class to handle ssl connections as well.
|
|
|
82 |
|
|
|
83 |
2. The ini files that provide the lookup for the country, subcountry and metro codes appears to have issues. In order to remedy the issue I enclosed all keys with tick marks. This issue will be explored later.
|
|
|
84 |
|