title: How to protect access to a url?
body: <p>I would need to create a php file that will do some work on my webserver and that will be called from a program on another server over the internet.
  Suppose the php file that will do the work is located at www.example.com/work.php</p>
  
  <p>What is the best way to protect unsollicited calls to the www.example.com/work.php?</p>
  
  <p>What I need is some mechanism so that when the intended program accesses the url (with some query string parameters), the work gets done, but if somebody type www.example.com/work.php in their browser, access will be denied and no work will be done.</p>
  
  <p>The way I've thought is to add some 'token' in the querystring that would be constructed by some algorithm from the calling program, a sample result could be to append to the url :</p>
  
  <pre><code>?key=randomKeyAtEachCall&amp;token=SomeHexadecimalResultCalculatedFromTheKey
  </code></pre>
  
  <p>and the key and token would be validated with a reverse algorithm on the php side.</p>
  
  <p>Is that safe,
  Are there any better idea?</p>