问题
How can I create different landing pages based on the country of the IP? For example, people from USA should get landing page 1 and people from Spain should get landing page 2.
回答1:
use http://freegeoip.net/json/64.34.119.12 64.34.119.12
being ip address, you will have not only country but also those field:
public string ip { get; set; }
public string country_code { get; set; }
public string country_name { get; set; }
public string region_code { get; set; }
public string region_name { get; set; }
public string metrocode { get; set; }
public string city { get; set; }
public string zipcode { get; set; }
public string latitude { get; set; }
public string longitude { get; set; }
回答2:
Page tab is really just regular web page loaded in iframe
within Facebook Page.
Default landing tab can only be defined to all non fan visitors of Facebook, but you can use country and locale for user part of signed_request passed to Page tab application canvas and provide different content for users from different locations/language-groups.
P.S. Mind that you cannot really ensure that country passed by Facebook is real user country, so use detection of country based on IP.
回答3:
Try this php code
<?php $ip = $_SERVER['REMOTE_ADDR'];
$json = file_get_contents("http://api.easyjquery.com/ips/?ip=".$ip."&full=true");
$json = json_decode($json,true);
$timezone = $json[localTimeZone];?>
来源:https://stackoverflow.com/questions/7778844/how-to-program-different-welcome-pages-based-on-country-ip