Difference between revisions of "IP2Geo"

From CDYNE Wiki
Jump to navigation Jump to search
imported>Nfesette
(Developer/Tester Information)
 
(21 intermediate revisions by 4 users not shown)
Line 19: Line 19:
  
 
===PHP Example===
 
===PHP Example===
<php>
+
<syntaxhighlight lang=php line=line>
class IP2Geo {
+
 
private $ip;
+
<?php
private $license;
+
 
public $response;
+
// Create a new soap client
+
$client = new SoapClient('http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl');
public function __construct($ip,$license)  
+
{
+
$param = array(
$this->license = $license;
+
'ipAddress' => 'IP ADDRESS',
$this->ip = $ip;
+
'licenseKey' => 'YOUR LICENSE KEY',
$response = $this->getResponse();
+
);
}
+
+
$result = $client->ResolveIP($param);
public function getResponse()
+
{
+
// View the response from CDYNE
$url = "http://ws.cdyne.com/ip2geo/ip2geo.asmx/ResolveIP";
+
print_r ($result);
$url .= "?ipAddress=" . $this->ip . "&licenseKey=" . $this->license;
+
 
$this->response = simplexml_load_file($url) or die("ERROR");
+
?>
}
+
</syntaxhighlight>
+
 
}
+
===JAVA Example===
function getRealIP() {
+
<syntaxhighlight lang=java line=line>
  if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
+
 
    $ip=$_SERVER['HTTP_CLIENT_IP'];
+
import java.io.ByteArrayOutputStream;
  } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+
import java.io.InputStream;
  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
+
import java.net.MalformedURLException;
} else {
+
import java.net.URL;
   $ip=$_SERVER['REMOTE_ADDR'];
+
import java.util.Properties;
}
+
import javax.xml.transform.OutputKeys;
  return $ip;
+
import javax.xml.transform.Source;
 +
import javax.xml.transform.Transformer;
 +
import javax.xml.transform.TransformerFactory;
 +
import javax.xml.transform.stream.StreamResult;
 +
import javax.xml.transform.stream.StreamSource;
 +
 
 +
public final class ResolveIP{   
 +
    public static void main(String[] args) {
 +
 
 +
          try{
 +
            URL url = new URL("http://ws.cdyne.com/ip2geo/ip2geo.asmx/ResolveIP?"
 +
                              + "ipAddress=IP ADDRESS"
 +
                              + "&licenseKey=YOUR LICENSE KEY");
 +
    try{
 +
    InputStream in = url.openStream();  
 +
    StreamSource source = new StreamSource(in);
 +
    printResult(source);
 +
}catch(java.io.IOException e){
 +
    e.printStackTrace();
 +
}
 +
}catch (MalformedURLException e){
 +
    e.printStackTrace();
 +
            }   
 +
    }   
 +
    private static void printResult(Source source) {      
 +
            try {           
 +
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
 +
            StreamResult sr = new StreamResult(bos);
 +
            Transformer trans = TransformerFactory.newInstance().newTransformer();
 +
            Properties oprops = new Properties();
 +
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
 +
            trans.setOutputProperties(oprops);
 +
            trans.transform(source, sr);          
 +
            System.out.println("**** Response ******");           
 +
            System.out.println(bos.toString());    
 +
 
 +
            bos.close();
 +
            System.out.println();      
 +
    } catch (Exception e) {           
 +
            }    
 +
    }
 
}
 
}
 +
</syntaxhighlight>
 +
 +
===VBScript Example===
 +
<syntaxhighlight lang=vb line=line>
 +
 +
Dim request, oXMLHttp, url
 +
url = "http://ws.cdyne.com/ip2geo/ip2geo.asmx"
 +
 +
request = "<?xml version='1.0' encoding='utf-8'?>" & _
 +
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
 +
"<soap:Body>" & _
 +
"<ResolveIP xmlns=""http://ws.cdyne.com/"">" & _
 +
"<ipAddress>IP ADDRESS</ipAddress>" & _
 +
"<licenseKey>YOUR LICENSE KEY</licenseKey>" & _
 +
"</ResolveIP>" & _
 +
"</soap:Body>" & _
 +
"</soap:Envelope>"
 +
 +
Set oXMLHttp = CreateObject("MSXML2.ServerXMLHTTP")
 +
oXMLHttp.open "POST", url, False
 +
oXMLHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
 +
oXMLHttp.send request
 +
response = oXMLHttp.responseText
 +
 +
MsgBox oXMLHTTP.responseText
 +
</syntaxhighlight>
 +
 +
=== CSharp Example ===
 +
<syntaxhighlight lang=csharp line=line>
 +
 +
/*http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl was added as a Web Reference and given the name WSDL*/
  
  $ip = getRealIP();
+
using System;
$key = 'XXXXXXXXXXXXXXXXXXXX;
+
using System.Collections.Generic;
$data = new IP2Geo($ip,$key);
+
using System.Linq;
var_dump($data);
+
using System.Text;
</php>
+
using IP2Geo.WSDL;  
 +
namespace IP2Geo
 +
{
 +
    class Program
 +
    {
 +
        static void Main(string[] args)
 +
        {
 +
            WSDL.IP2Geo ip = new WSDL.IP2Geo();
 +
            WSDL.IPInformation ipr = ip.ResolveIP("IP ADDRESS", "YOUR LICENSE KEY");
 +
           
 +
            Console.WriteLine("City: " + (String.IsNullOrEmpty(ipr.City) ? "No Information Found" : ipr.City));
 +
            Console.WriteLine("State: " + (String.IsNullOrEmpty(ipr.StateProvince) ? "No Information Found" : ipr.StateProvince));
 +
            Console.WriteLine("Country: " + (String.IsNullOrEmpty(ipr.Country) ? "No Information Found" : ipr.Country));
 +
            Console.WriteLine("Organization: " + (String.IsNullOrEmpty(ipr.Organization) ? "No Information Found" : ipr.Organization));
 +
            Console.WriteLine("Latitude: " + ipr.Latitude);
 +
            Console.WriteLine("Longitude: " + ipr.Longitude);
 +
            Console.WriteLine("Area Code: " + (String.IsNullOrEmpty(ipr.AreaCode) ? "No Information Found" : ipr.AreaCode));
 +
            Console.WriteLine("Time Zone: " + (String.IsNullOrEmpty(ipr.TimeZone) ? "No Information Found" : ipr.TimeZone));
 +
            Console.WriteLine("Daylight Savings: " + ipr.HasDaylightSavings);
 +
            Console.WriteLine("Certainty: " + ipr.Certainty + "%");
 +
            Console.WriteLine("Region Name: " + (String.IsNullOrEmpty(ipr.RegionName) ? "No Information Found" : ipr.RegionName));
 +
            Console.WriteLine("Country Code: " + (String.IsNullOrEmpty(ipr.CountryCode) ? "No Information Found" : ipr.CountryCode));           
 +
           
 +
            Console.ReadLine();
 +
        }
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 
 +
=== VB.Net Example ===
 +
<syntaxhighlight lang=vbnet line=line>
 +
 
 +
'http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl was added as a Web Reference and given the name WSDL
 +
 
 +
Imports ResolveIP.WSDL
 +
Module Module1
 +
 
 +
    Sub Main()
 +
        Dim IP As New IP2Geo()
 +
        Dim IPR = IP.ResolveIP("IP ADDRESS", "YOUR LICENSE KEY")
 +
 
 +
        Console.WriteLine("City: " & (If(String.IsNullOrEmpty(IPR.City), "No Information Found", IPR.City)))
 +
        Console.WriteLine("State: " & (If(String.IsNullOrEmpty(IPR.StateProvince), "No Information Found", IPR.City)))
 +
        Console.WriteLine("Country: " & (If(String.IsNullOrEmpty(IPR.Country), "No Information Found", IPR.Country)))
 +
        Console.WriteLine("Organization: " & (If(String.IsNullOrEmpty(IPR.Organization), "No Information Found", IPR.Organization)))
 +
        Console.WriteLine("Latitude: " & IPR.Latitude)
 +
        Console.WriteLine("Longitude: " & IPR.Longitude)
 +
        Console.WriteLine("Area Code: " & (If(String.IsNullOrEmpty(IPR.AreaCode), "No Information Found", IPR.Organization)))
 +
        Console.WriteLine("Time Zone: " & (If(String.IsNullOrEmpty(IPR.TimeZone), "No Information Found", IPR.TimeZone)))
 +
        Console.WriteLine("Daylight Savings: " & IPR.HasDaylightSavings)
 +
        Console.WriteLine("Certainty: " & IPR.Certainty & "%")
 +
        Console.WriteLine("Region Name: " & (If(String.IsNullOrEmpty(IPR.RegionName), "No Information Found", IPR.RegionName)))
 +
        Console.WriteLine("Country Code: " & (If(String.IsNullOrEmpty(IPR.CountryCode), "No Information Found", IPR.CountryCode)))
 +
 
 +
        Console.ReadLine()
 +
 
 +
    End Sub
 +
 
 +
End Module
 +
</syntaxhighlight>
  
 
=== Web Service source code examples ===
 
=== Web Service source code examples ===
Line 84: Line 214:
 
=== Pricing ===
 
=== Pricing ===
  
Pricing for all CDYNE Web Services is based off a set monthly maintenance fee and a per-transaction fee. CDYNE does not require a contract and there are absolutely no start-up or cancellation fees. CDYNE services are post-pay. Your credit card will not be charged until one month from sign-up date and will be billed monthly thereafter unless you deactivate or cancel services. Net 30 billing is available upon application approval. <br>
+
[http://cdyne.com/pricing/default.aspx?product=4 Pricing]
 
 
[http://www.cdyne.com/products/pricing.aspx?PGID=810827F7-1478-4A20-B46D-C1425ECA46BB Calculate estimated monthly pricing]
 
 
 
{| class="wikitable" cellspacing="5"
 
|-
 
! Service
 
! align="left"| Trans. Min.
 
! align="left"| Trans. Max.
 
! align="left"| Monthly
 
|-
 
 
 
| IP2Geo Monthly Fee
 
|
 
|
 
| $20.00
 
|-
 
 
 
| IP2Geo Trans fee
 
| Zero
 
| 1,000
 
| $0.02
 
|-
 
 
 
| IP2Geo Trans fee
 
| 1,001
 
| 3,000
 
| $0.01
 
|-
 
 
 
| IP2Geo Trans fee
 
| 3,001
 
| Unlimited
 
| $0.0090
 
|-
 
 
 
|}
 

Latest revision as of 11:11, 24 January 2019

Web Personalization for One-to-One Web Marketing

The IP2Geo® Web Service resolves IP addresses to Network Owner Name, City, State/Province, and Country. In most U.S. cities, it will also provide extra information such as Area Code and Latitude/Longitude. This service allows for the integration of location & distance information and other geographic intelligence into your application databases, business processes and web sites.

IP2Geo gives you easy access to numerous data points that you can use to impress your clients. From geographically customized menus to log file analysis, your targeted site visitors will be impressed when they see specific information on their location. The real-time technology can even be used to trigger special "preferred location" promotions.

This service is also used to validate users by IP address to weed out hackers and other fraudsters.

All of CDYNE's Web services are built on XML standards and are delivered via a secure Internet connection. This real-time Web service dynamically delivers value-added information at the point of customer interaction or to the client database for true enterprise intelligence, positively affecting the quality of resultant analytics, customer relationships and the bottom line.

DEVELOPER RESOURCES

General Information

IP2Geo - IP Address to Geographic information.

Developer/Tester Information

PHP Example

 1 <?php
 2 
 3 // Create a new soap client 
 4 $client = new SoapClient('http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl');
 5  
 6 $param = array(
 7  'ipAddress' => 'IP ADDRESS',
 8  'licenseKey' => 'YOUR LICENSE KEY',
 9 );
10  
11 $result = $client->ResolveIP($param);
12  
13 // View the response from CDYNE
14 print_r ($result);
15 
16 ?>

JAVA Example

 1 import java.io.ByteArrayOutputStream;
 2 import java.io.InputStream;
 3 import java.net.MalformedURLException;
 4 import java.net.URL; 
 5 import java.util.Properties;
 6 import javax.xml.transform.OutputKeys;
 7 import javax.xml.transform.Source;
 8 import javax.xml.transform.Transformer;
 9 import javax.xml.transform.TransformerFactory;
10 import javax.xml.transform.stream.StreamResult;
11 import javax.xml.transform.stream.StreamSource;
12 
13 public final class ResolveIP{     	
14     public static void main(String[] args) { 	
15 
16            try{		
17             URL url = new URL("http://ws.cdyne.com/ip2geo/ip2geo.asmx/ResolveIP?"
18                                + "ipAddress=IP ADDRESS"
19                                + "&licenseKey=YOUR LICENSE KEY");		
20     try{			
21     InputStream in = url.openStream(); 
22     StreamSource source = new StreamSource(in); 			
23     printResult(source);	
24 }catch(java.io.IOException e){			
25     e.printStackTrace();		
26 }		
27 }catch (MalformedURLException e){		
28     e.printStackTrace();	
29             }     
30     }     
31     private static void printResult(Source source) {        
32             try {            
33             ByteArrayOutputStream bos = new ByteArrayOutputStream();
34             StreamResult sr = new StreamResult(bos);
35             Transformer trans = TransformerFactory.newInstance().newTransformer();
36             Properties oprops = new Properties();
37             oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
38             trans.setOutputProperties(oprops);
39             trans.transform(source, sr);            
40             System.out.println("**** Response ******");            
41             System.out.println(bos.toString());   
42 
43             bos.close();
44             System.out.println();        
45     } catch (Exception e) {            
46             }      
47     }
48 }

VBScript Example

 1 Dim request, oXMLHttp, url
 2 url = "http://ws.cdyne.com/ip2geo/ip2geo.asmx"
 3 
 4 request = "<?xml version='1.0' encoding='utf-8'?>" & _
 5 "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
 6 "<soap:Body>" & _
 7 "<ResolveIP xmlns=""http://ws.cdyne.com/"">" & _
 8 "<ipAddress>IP ADDRESS</ipAddress>" & _
 9 "<licenseKey>YOUR LICENSE KEY</licenseKey>" & _
10 "</ResolveIP>" & _
11 "</soap:Body>" & _
12 "</soap:Envelope>"
13 
14 Set oXMLHttp = CreateObject("MSXML2.ServerXMLHTTP")
15 oXMLHttp.open "POST", url, False
16 oXMLHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
17 oXMLHttp.send request
18 response = oXMLHttp.responseText
19 
20 MsgBox oXMLHTTP.responseText

CSharp Example

 1 /*http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl was added as a Web Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using IP2Geo.WSDL;  
 8 namespace IP2Geo
 9 {
10     class Program
11     {
12         static void Main(string[] args)
13         {
14             WSDL.IP2Geo ip = new WSDL.IP2Geo();
15             WSDL.IPInformation ipr = ip.ResolveIP("IP ADDRESS", "YOUR LICENSE KEY");
16             
17             Console.WriteLine("City: " + (String.IsNullOrEmpty(ipr.City) ? "No Information Found" : ipr.City));
18             Console.WriteLine("State: " + (String.IsNullOrEmpty(ipr.StateProvince) ? "No Information Found" : ipr.StateProvince));
19             Console.WriteLine("Country: " + (String.IsNullOrEmpty(ipr.Country) ? "No Information Found" : ipr.Country));
20             Console.WriteLine("Organization: " + (String.IsNullOrEmpty(ipr.Organization) ? "No Information Found" : ipr.Organization));
21             Console.WriteLine("Latitude: " + ipr.Latitude);
22             Console.WriteLine("Longitude: " + ipr.Longitude);
23             Console.WriteLine("Area Code: " + (String.IsNullOrEmpty(ipr.AreaCode) ? "No Information Found" : ipr.AreaCode));
24             Console.WriteLine("Time Zone: " + (String.IsNullOrEmpty(ipr.TimeZone) ? "No Information Found" : ipr.TimeZone));
25             Console.WriteLine("Daylight Savings: " + ipr.HasDaylightSavings);
26             Console.WriteLine("Certainty: " + ipr.Certainty + "%");
27             Console.WriteLine("Region Name: " + (String.IsNullOrEmpty(ipr.RegionName) ? "No Information Found" : ipr.RegionName));
28             Console.WriteLine("Country Code: " + (String.IsNullOrEmpty(ipr.CountryCode) ? "No Information Found" : ipr.CountryCode));            
29             
30             Console.ReadLine();
31         }
32     }
33 }

VB.Net Example

 1 'http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl was added as a Web Reference and given the name WSDL
 2 
 3 Imports ResolveIP.WSDL
 4 Module Module1
 5 
 6     Sub Main()
 7         Dim IP As New IP2Geo()
 8         Dim IPR = IP.ResolveIP("IP ADDRESS", "YOUR LICENSE KEY")
 9 
10         Console.WriteLine("City: " & (If(String.IsNullOrEmpty(IPR.City), "No Information Found", IPR.City)))
11         Console.WriteLine("State: " & (If(String.IsNullOrEmpty(IPR.StateProvince), "No Information Found", IPR.City)))
12         Console.WriteLine("Country: " & (If(String.IsNullOrEmpty(IPR.Country), "No Information Found", IPR.Country)))
13         Console.WriteLine("Organization: " & (If(String.IsNullOrEmpty(IPR.Organization), "No Information Found", IPR.Organization)))
14         Console.WriteLine("Latitude: " & IPR.Latitude)
15         Console.WriteLine("Longitude: " & IPR.Longitude)
16         Console.WriteLine("Area Code: " & (If(String.IsNullOrEmpty(IPR.AreaCode), "No Information Found", IPR.Organization)))
17         Console.WriteLine("Time Zone: " & (If(String.IsNullOrEmpty(IPR.TimeZone), "No Information Found", IPR.TimeZone)))
18         Console.WriteLine("Daylight Savings: " & IPR.HasDaylightSavings)
19         Console.WriteLine("Certainty: " & IPR.Certainty & "%")
20         Console.WriteLine("Region Name: " & (If(String.IsNullOrEmpty(IPR.RegionName), "No Information Found", IPR.RegionName)))
21         Console.WriteLine("Country Code: " & (If(String.IsNullOrEmpty(IPR.CountryCode), "No Information Found", IPR.CountryCode)))
22 
23         Console.ReadLine()
24 
25     End Sub
26 
27 End Module

Web Service source code examples

JSP
Flash
CFM
ASP.NET
ASP
PHP

LICENSE KEYS AND PRICING

Free Trial License Keys

  • CDYNE offers trial license keys for all Web Services so that you may test the APIs for free.
  • Trial keys do not expire, and are limited to approximately 50 transactions.
  • Normal processing time for trial key requests during normal business hours (M-F, 9-6 eastern) typically ranges from ten minutes to two hours.
  • Sign up here for a free trial IP2Geo license key.

Production (Account) License Keys

  • Sign up here for a production IP2Geo license key.
  • Upon registration, your account will be suspended for verification by default.
  • The account verification process takes less than one business day to complete for account activation.
  • You may call 1-800-984-3710 to expedite the verification process over the phone.

Pricing

Pricing