How to call a PHP script from a PHP script on another server
I have access to two distinct servers. I would like one's PHP script to call a URL on the other's server (and pass a secret variable). However, I want to make sure nobody else can spoof this call.
What is the best way to do this, short of SSL? I was thinking about hashing but anyone can read the POST request's hash and spoof it.
T开发者_运维知识库hanks!
Maybe you need SSH. You call the other script through ssh, which means no one else can see what's going on. See this blog
There are many ways to do this
If your servers have static ip's, you could check the IP address. (If you are on shared hosting other people on the server will have the same IP)
You can encrypt the data with AES and decrypt it on the other end. Of course you'd have to encode this (using base64_encode, for example) before POST'ing it.
What about using cURL and a SSL connection?
Your best bet is to employ some kind of encryption to encrypt the variable. RSA is a secure, common one that has examples ready to copy/paste in php. It might be a bit hard to wrap your head around, but once you get it working, it is extremely secure.
Honestly your easiest way is SSL encryption.
I'm not sure that is possible at all. If the PHP-Script of ServerA calls the script on ServerB, that script will be interpreted by ServerB, it generates an output HTML/Whatever and gives that output to the script of ServerA.
AFAIK it's not possible to access a PHP-Script before it is interpreted, as long as you don't have direct FTP-Access on it.
精彩评论