Copyright © 2014 by mTLD Top Level Domain Limited. All rights reserved.
Portions copyright © 2008 by Argo Interactive Limited.
Portions copyright © 2008 by Nokia Inc.
Portions copyright © 2008 by Telecom Italia Mobile S.p.A.
Portions copyright © 2008 by Volantis Systems Limited.
Portions copyright © 2002-2008 by Andreas Staeding.
Portions copyright © 2008 by Zandan.
dotMobi
The main class for the Carrier Detection API. Used to load the data file and to perform lookups using IPv4 addresses. For usage in a Web App it is recommended to use the CarrierApiWeb (CarrierApiWeb.php) class so you dont have to pass the client's IP address manually.
Please note that it is advisable to load only a single instance of this class to avoid multiple loadings of the data file.
Example usage:
ip = '62.40.34.220' carrier_api = CarrierApi.new carrier_api.load_data_from_file '/path/to/sample.dat' # get all properties props = carrier_api.get_properties ip # .... use the properties .... if props.has_key?'mobileNetworkOperator' operator_name = props.get 'mobileNetworkOperator' puts 'mobileNetworkOperator: ' + operator_name end # get a single property mcc_prop = carrier_api.get_property ip, 'mcc' if !mcc_prop.nil? puts 'MCC: ' + mcc_prop end
Please see the code in the examples directory for additional samples.
A list of HTTP headers to choose the original client IP address from. In addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final fallback.
Returns the data file copyright text.
return
the copyright
Returns the data file creation date in ISO8601 format.
return
the creation date
Returns the version of the data file.
return
the version
Get the most suitable IP address from the given key_vals set of HTTP headers. This function checks the headers defined in HEADERS_TO_CHECK.
Get the Carrier properties for a given IP address.
ipv4
The IP address to find carrier properties for, or an array of HTTP
header values keyed by HTTP headers names. Both must be given as a string.
return
The found properties or null of no properties found.
Try and get a specific property for a given IP address.
Note: if multiple properties are needed for the same IP it is more efficient to call getProperties() once than repeated calls to getProperty().
ipv4
The IP address to find carrier properties for, or an array of HTTP
header values keyed by HTTP headers names. Both must be given as a string.
Name of the property to return
return
Property object or nil of no property found
A set of all the possible property names. The Set contains PropertyName objects that each have a name and an associated data type.
return
Array of possible property names.
An IP address is considered public if it is not in any of the following ranges:
1) any local address IP: 0 2) a local loopback address range: 127/8 3) a site local address i.e. IP is in any of the ranges: range: 10/8 range: 172.16/12 range: 192.168/16 4) a link local address range: 169.254/16
ip
IP address to check
return
True if it is public, false if it is invalid or is not public
Load the data file from the provided path. The data file is reloaded every time this method is called.
path
The path on disk to the data file.