Function Reference: geodir_ga_callback
Summary
This function has not been documented yet.
Source File
geodir_ga_callback() is located in geodirectory-admin/admin_hooks_actions.php [Line: 2356]
Source Code
function geodir_ga_callback(){ if(isset($_REQUEST['code']) && $_REQUEST['code']) { $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; $code = "code=".$_REQUEST['code']; $grant_type = "&grant_type=authorization_code"; $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; $client_id = "&client_id=".get_option('geodir_ga_client_id'); $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; $response = wp_remote_post($auth_url, array('timeout' => 15)); //print_r($response); $error_msg = __('Something went wrong','geodirectory'); if(!empty($response['response']['code']) && $response['response']['code']==200){ $parts = json_decode($response['body']); //print_r($parts); if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{ update_option('gd_ga_access_token', $parts->access_token); update_option('gd_ga_refresh_token', $parts->refresh_token); ?>error)){ echo $parts->error.": ".$parts->error_description;exit; }else{ echo $error_msg." - #2";exit; } }else{ echo $error_msg." - #3";exit; } } exit; }