Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@turtlepod
Created August 24, 2017 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turtlepod/1228e0ec1707c85c25dbadf8ba54151f to your computer and use it in GitHub Desktop.
Save turtlepod/1228e0ec1707c85c25dbadf8ba54151f to your computer and use it in GitHub Desktop.
Google Maps API Key Test
<?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