title: How would I go about preventing hotlinking of a PHP web service script that runs a query on a MySQL database and outputs it in JSON form?
body: <p><strong>Introduction and background</strong></p>
  
  <p>I have a MySQL database of Lottery Results which my Android application queries to get the results via a PHP web service script which connects to the database, does a query for the top 10 and returns JSON data for the Android client to parse and then display.</p>
  
  <p>I have the server hosted and it uses Cpannel (cannot find the version number).</p>
  
  <p>In terms of the Android app (java program) The full URLs of php script are stored in a String. I fear if the program got decompiled they could get access to this string. I am using pro-guard to obfuscate the code but this does not hide actual values given to Strings or variables.  </p>
  
  <p><strong>The actual Problem</strong></p>
  
  <p>How would I prevent others (if they got the actual URL of the PHP script location) to prevent them from leaching the results I provide just by running the script (this would cost me bandwidth usage). I tested it and I could actually get the JSON data output if I input the full URL of the script. </p>
  
  <p><strong>What I have done so far</strong></p>
  
  <p>Im new to this server hosting and administration. So far I disabled indexing on the directory which contains the PHP scripts just in case someone found them that way. </p>
  
  <p>I was looking into setting permissions for the script file but ended up actually blocking legitimate use of it. At the moment they are 644. I cannot remember which ones I tried. </p>
  
  <p>I found various hotlinking tutorials but these seem to be for images and multimedia but not specifically a script which outputs JSON data. Please help me. </p>
  
  <p><strong>What I am looking for</strong></p>
  
  <p>I don't have any code to show but I am looking for advice for those who have been through the same problem and point me into a direction to which I can research, investigate and build a solution from.</p>
  
  <p>Thank your for your time in reading </p>