Created
October 19, 2013 18:28
-
-
Save nonoesp/7059622 to your computer and use it in GitHub Desktop.
PHP key-restricted content with GET. If high security is needed it would be better to use POST.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Sample to get a url variable through GET method | |
Example URL: ../sample.php?apikey=MY_KEY | |
*/ | |
// Define the API key here | |
$APIKey = 'MY_KEY'; // this is the key that the app has to send on the URL | |
// Obtain the GET variable apikey | |
$getAPIKey = $_GET['apikey']; // this is the key sent by the app on the URL | |
// Check if keys match each other | |
if ($APIKey == $getAPIKey) { | |
// Show JSON data here. | |
echo "Show data."; | |
} else { | |
// Do not show JSON data. | |
echo "Do not show data."; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment