Created
August 24, 2017 14:28
-
-
Save turtlepod/1228e0ec1707c85c25dbadf8ba54151f to your computer and use it in GitHub Desktop.
Google Maps API Key Test
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 | |
/** | |
* Google API tester. | |
*/ | |
function my_gmaps_key_test( $key ) { | |
$url = add_query_arg( $args = array( | |
'address' => 'Genbu Media', | |
), 'https://maps.googleapis.com/maps/api/geocode/json' ); | |
$result = wp_remote_get( | |
esc_url_raw( $url ), | |
array( | |
'timeout' => 5, | |
'redirection' => 1, | |
'httpversion' => '1.1', | |
'user-agent' => 'WordPress/Na Na Na Batman; ', | |
'sslverify' => false, | |
) | |
); | |
$result = wp_remote_retrieve_body( $result ); | |
return json_decode( $result, true ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment