diff --git a/includes/collective-access-api.php b/includes/collective-access-api.php index 1b68303..c51d18f 100644 --- a/includes/collective-access-api.php +++ b/includes/collective-access-api.php @@ -20,8 +20,8 @@ if (!defined('ABSPATH')) { */ function carhop_ca_api_request($endpoint, $params = array(), $method = 'GET') { - // Base URL of the McCord Museum's CollectiveAccess instance - $base_url = 'https://collections.musee-mccord.qc.ca'; + // Base URL of the McCord Stewart Museum's CollectiveAccess instance + $base_url = 'https://collections.musee-mccord-stewart.ca'; // Build the full URL $url = trailingslashit($base_url) . 'api/' . ltrim($endpoint, '/'); @@ -128,3 +128,32 @@ function carhop_test_ca_api() // Log the results error_log('CollectiveAccess API Test Results: ' . print_r($objects, true)); } + +/** + * Test and display the API endpoint URL + */ +function carhop_test_ca_endpoint() +{ + $base_url = 'https://collections.musee-mccord.qc.ca'; + $endpoint = 'objects'; + $params = ['limit' => 1]; + + $url = trailingslashit($base_url) . 'api/' . ltrim($endpoint, '/'); + if (!empty($params)) { + $url = add_query_arg($params, $url); + } + + echo '
'; + echo '

API Endpoint URL: ' . esc_url($url) . '

'; + + // Test the connection + $response = wp_remote_get($url); + if (is_wp_error($response)) { + echo '

Connection Error: ' . esc_html($response->get_error_message()) . '

'; + } else { + $status = wp_remote_retrieve_response_code($response); + echo '

Response Status: ' . esc_html($status) . '

'; + } + + echo '
'; +}