Jump to content

How to integrate XE.com into a website.


theITvideos

Recommended Posts

Hi there,

 

This forum has been helpful to me so far. I'd like to thank you for your help.

 

Now the question is, we will be using xe.com services for our shopping cart and prices. Based to the customer's location the currency must change.

 

For example, if the customer is sitting in Europe, the currency for the product and the shopping cart will be displayed in Euros, similarly for the US customers it will be in USD.

 

I would like to know how we can do this using xe.com and what steps are required.

 

Any comments/feedbacks are always welcome! :)

 

Thank you!

 

 

Link to comment
Share on other sites

Thanks for the message.

I am running on WAMP server.  I am trying this now.

 

<?php
$country = geoip_country_code_by_name('www.example.com');
echo $country;
if ($country) {
	echo 'This host is located in: ' . $country;
}
?>

 

Now this gives errors like:

 

Fatal error: Call to undefined function geoip_country_code_by_name() in C:\wamp\www\test\demo.php on line 7

 

I guess i need to install PECL thats what it says in the installation section of geoip_country_code_by_name() function.

 

Has anyone installed PECL on WAMP Server or anyone faced problem using this function: geoip_country_code_by_name() for getting users country name?

 

Please reply.

 

Best regards!

Link to comment
Share on other sites

Thanks for the reply.

 

I put in my folder the 2 files you mentioned that is, GeoIP.dat and GeoIP.inc:

 

  • GeoIP.dat downloaded from:

http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

  • GeoIP.inc downloaded from

http://geolite.maxmind.com/download/geoip/api/php/geoip.inc


After I included the above 2 files in the folder, I included their references in my .php file:

<?php	
include("geoip.inc");
include("GeoIP.dat");
?>

 

But I get an error, I noticed that the function geoip_country_code_by_name() which is defined in geoip.inc file, takes two arguments:

 

function geoip_country_name_by_name($gi, $name) {
  $country_id = geoip_country_id_by_name($gi,$name);
  if ($country_id !== false) {
        return $gi->GEOIP_COUNTRY_NAMES[$country_id];
  }
  return false;
}

 

Where as in the PHP user guide, they have demonstrated using single argument:

 

<?php
$country = geoip_country_code_by_name('www.example.com');
if ($country) {
    echo 'This host is located in: ' . $country;
}
?>

Source: http://www.php.net/manual/en/function.geoip-country-code-by-name.php

 

How can we go about fixing this.

 

Any comments of feedback is always welcome.

 

Thank you!

Link to comment
Share on other sites

  • 2 months later...

Use GeoIP to grab people's location through there ip address then

Use SimpleXML to parse the currency through the xe.com website

 

Thank you for your reply. I can now detect the visitors country and can tell which country the user is coming from thru the IP address. :)

 

Now I just need the second step, that is, using the xe.com Datafeed in my website for currency conversions.

 

All the rates are stored in Australian Dollars in the Database. I just need to convert them (using xe.com datafeed) to visitors country.

 

How can I integrate the xe.com Datafeed my on PHP website. Any sample or working  code or something that you can refer to me that I can look at just to get some idea.

 

Thank you very much! :)

 

All comments and feedbacks are always welcomed!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.