php ip 位置
我有一个简单的问题。 是否可以通过 IP 位置重定向我网站中的人员?
例子: 一个人在网站上导航,何时去付款,如果 IP 位置来自葡萄牙,则通过银行转账付款,如果不是通过 Paypal 付款?
对不起我的英语。 谢谢, 佩德罗·洛佩斯
I have a simple question.
Is it possible to redirect people in my website by the IP location?
Example:
one person navigates on the site and when go to pay, if the ip location is from Portugal pay by bank transfer, if not pay by paypal?
sorry my english.
thanks,
Pedro Lopes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然,你可以做到。但我认为不太准确。
例如,我来自希腊科孚岛。我的地理位置始终指向希腊雅典。
另一个例子。出于个人原因,我试图阻止整个国家/地区访问我的网站。虽然这项工作很好,但并不完美,但我仍然有来自那个国家的访问。
Of course and you can do it. But I thing that not so accurate.
In example I am from Corfu, Greece. My geolocation is always pointing in Athens Greece.
Another example. I have try to lock out a whole country from accessing my web site for a personal reason. But while that work good, is not perfect, still I have visits from that country.
是的。完全可以根据访问者的 IP 位置进行跟踪和重定向。
您可以使用ipgeolocation.io API。每月最多可免费使用 30K 请求(每天 1K 请求)。它具有可用于 PHP、Java 等多种语言的集成。
Yes. It is totally possible to track and redirect based on visitor's IP-Location.
You can use ipgeolocation.io API. It is free for use up to 30K requests per month (1K requests per day). It has integrations available for many languages like PHP, Java, etc.
最后,听起来您只关心将它们发送到哪个计费平台。允许您的用户从您支持的国家/地区列表中选择他们的国家/地区要容易得多且更可靠。这比基于 IP 的解决方案更准确,并且可以为可能不在家里使用计算机的旅行者提供解决方案。 链接中存在更多基于 IP 的位置的潜在问题 @ Piskvor 在上面的评论中提供。
对于您给出的示例,您可以提供标准帐单地址表格。如果用户选择葡萄牙以外的国家/地区,则银行转账付款类型将被禁用,并选择 PayPal。
In the end, it sounds like you only really care about which billing platform to send them to. It is far easier and more reliable to allow your users to select their country from a list of countries you support. This is both more accurate than the IP-based solution and it solves for travelers who may not be at their home computer. There are more potential issues with IP-based location in the link @Piskvor provided in the comments above.
For the example you gave, you could offer your standard billing address form. If the user selects a country other than Portugal, the bank transfer tender type gets disabled, and PayPal is selected.