How to program different welcome pages based on country IP?

廉价感情. 提交于 2019-12-06 17:12:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!