如何根据国家IP编写不同的欢迎页面?

发布于 2024-12-10 05:46:49 字数 68 浏览 6 评论 0 原文

如何根据 IP 所在国家/地区创建不同的登陆页面?例如,来自美国的用户应访问着陆页 1,来自西班牙的用户应访问着陆页 2。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒儿 2024-12-17 05:46:49

使用 http://freegeoip.net/json/64.34.119.12 64.34.119.12< /code> 作为 IP 地址,您不仅会有国家/地区,还有这些字段:

    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; }

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; }
如果没结果 2024-12-17 05:46:49

页面选项卡实际上只是 Facebook 页面内 iframe 中加载的常规网页。

默认登陆选项卡只能定义给 Facebook 的所有非粉丝访问者,但您可以使用 国家/地区区域设置 作为用户部分="http://developers.facebook.com/docs/authentication/signed_request/" rel="nofollow">signed_request 传递到页面选项卡应用程序画布,并为来自不同位置/语言组的用户提供不同的内容。

聚苯乙烯
请注意,您无法真正确保 Facebook 传递的国家/地区是真实的用户国家/地区,因此请使用基于 IP 的国家/地区检测。

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.

纵山崖 2024-12-17 05:46:49

试试这个 php 代码

  <?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];?>

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];?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文