Skip to content

Instantly share code, notes, and snippets.

@alanef
Created June 30, 2021 18:50
Show Gist options
  • Select an option

  • Save alanef/9aaffbddd1c3522dff195822fe1386d4 to your computer and use it in GitHub Desktop.

Select an option

Save alanef/9aaffbddd1c3522dff195822fe1386d4 to your computer and use it in GitHub Desktop.
$url = "https://v3.openstates.org/jurisdictions';
$args = array(
'headers' => array (
'X-API-KEY' => 'your api key here'
),
);
$response = wp_remote_get( $url, $args );
$response_code = wp_remote_retrieve_response_code( $response );
if ( 200 != $response_code ) {
// handle non sucess e.g. error_log
}
$decoded = json_decode( wp_remote_retrieve_body( $response ), true ); // decodes json into an array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment