IP2Currency: Python Sample Code

The sample code below provide you an example on how to obtain the latest currency exchange rate and the homeland currency by visitor's IP address.


#!/bin/python
#//////////////////////////////////////////////////////////////////////////////////
#//
#// This source code is only licensed to our premium subscribers. It is provided "as is" and without warranties.
#//
#// http://www.fraudlabs.com @ All Rights Reserved 2012
#//
#/////////////////////////////////////////////////////////////////////////////////
import sys, urllib, string, SOAPpy
from xml.sax import parse, ContentHandler, SAXParseException
from SOAPpy import SOAPProxy
from SOAPpy import Types

SOAPpy.Config.buildWithNamespacePrefix=0
SOAPpy.Config.debug=1

server=SOAPProxy("http://v1.fraudlabs.com/ip2currencywebservice.asmx", namespace="http://v1.fraudlabs.com/", noroot=1, soapaction="http://v1.fraudlabs.com/ip2currencywebservice.asmx/IP2Currency")

# Change these values to the address to validate
license = "<Enter License Key>"
visitorip = "68.142.197.65"
fromcurrencycode = "CAD"
tocurrencycode = ""
fromamount = ""

myarray = {}

myarray["VISITORIP"]=visitorip
myarray["FROMCURRENCYCODE"]=fromcurrencycode
myarray["TOCURRENCYCODE"]=tocurrencycode
myarray["FROMAMOUNT"]=fromamount
myarray["LICENSE"]=license

result = server.IP2Currency(inputdata=myarray)

print result

Download the source code
You need a license key for the solution. And, it is free and available at IP2Currency Free License