<?php if (isset($_GET['apikey'])) { $apikey = trim($_GET['apikey']); $apisecret = trim($_GET['apisecret']); $apicred = $_GET['api_request']; if (!isValidApiSettings($apikey)) { echo '<div id="Error">Please enter a valid API Key.</div>'; } elseif (!isValidApiSettings($apisecret)) { echo '<div id="Error">Please enter a valid API Secret.</div>'; } elseif (check_api_settings($apikey, $apisecret, $apicred)) { echo check_api_settings($apikey, $apisecret, $apicred); } } /** * Check apikey and secret is valid. */ function isValidApiSettings($apikey) { return !empty($apikey) && preg_match('/^\\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\\}?$/i', $apikey); } /** * Check api credential settings. */ function check_api_settings($apikey, $apisecret, $apicred) { $JsonResponse = ''; if (isset($apikey)) { $ValidateUrl = "https://hub.loginradius.com/ping/{$apikey}/{$apisecret}"; if ($apicred == 'curl') { if (in_array('curl', get_loaded_extensions()) and function_exists('curl_exec')) {
<?php if (isset($_GET['api_id'])) { $api_id = trim($_GET['api_id']); $api_secret = trim($_GET['api_secret']); $apicred = $_GET['api_request']; check_api_settings($api_id, $api_secret, $apicred); } /** * Check api credential settings. */ function check_api_settings($api_id, $api_secret, $apicred) { if (isset($api_id)) { $url = "https://graph.facebook.com/v2.3/" . $api_id . "?access_token=" . $api_id . '|' . $api_secret; if ($apicred == 'curl') { if (in_array('curl', get_loaded_extensions()) and function_exists('curl_exec')) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $app_response = curl_exec($curl); $curl_response = curl_getinfo($curl); curl_close($curl); $app_result = json_decode($app_response); if ($curl_response['http_code'] == 200) { echo '<div id="apisuccess">Your API settings working perfectly. Please Save your current Settings.</div>'; die; } else { echo '<div id="apierror">Returned error: curl response =' . $curl_response['http_code'] . ' ,Facebook response='; print_r($app_response) . '</div>';