更新时间:2023-09-20 16:06:28
我的服务器不使用 Rails,我使用 PHP.但我认为方法是一样的.为您的请求添加一种键.我总是将其作为 POST 值.在您的应用程序中对此密钥进行硬编码.在 PHP 中,我在服务器上的脚本第一行执行以下操作:
I don't use Rails for my Server, i use PHP. But I think the approach is the same. Add a sort of a key to your Request. I do it always as a POST value. Hardcode this key in your application. In PHP I do the following on my server in the first line of the scripts:
if ($_POST['secret'] != "YOUR_KEY") {
die('You are not allowed to use this Webservice.');
}
我使用字符串作为UKZ6b79MKHK"而不是 YOUR_KEY 等等......到目前为止它对我的东西有效.;-)我希望我的回答对你有所帮助,即使它不是 Rails.
Instead of YOUR_KEY I use strings as "UKZ6b79MKHK" and so on... So far it worked for my stuff. ;-) I hope my answer hepls you even if it's not Rails.
桑德罗·迈耶