Skip to content

Instantly share code, notes, and snippets.

@kartikparmar
Last active June 7, 2021 15:27
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 kartikparmar/13575c5573620af8e7f04e3cf05dcd0c to your computer and use it in GitHub Desktop.
Save kartikparmar/13575c5573620af8e7f04e3cf05dcd0c to your computer and use it in GitHub Desktop.
<?php
$consumer_key = 'ck_b6dab226d72e3b3da3462f9b51bc672b886f8f85';
$consumer_secret = 'cs_912b18aeedb2883a9c53f877a3c77fc7c0082fc4';
$url = rest_url( 'wp/v2/bkap-bookings/16180/' );
$url = add_query_arg(
array(
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret
),
$url
);
$response = wp_remote_get( $url, array( 'sslverify' => false ) );
// Check the response code.
if ( wp_remote_retrieve_response_code( $response ) != 200 || ( empty( wp_remote_retrieve_body( $response ) ) ) ) {
// If not a 200, HTTP request failed.
die( 'There was an error attempting to access the API.' );
}
$bookings = json_decode( wp_remote_retrieve_body( $response ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment