We create amazing things
What we do
// Define the API endpoint
$url = 'https://bosslabsmediagroup.com/wp-json/wc/v3/products';
// Set up your WooCommerce API credentials
$consumer_key = 'ck_0a330afbca7466824ad1a35497e4ea1a526a9509';
$consumer_secret ='cs_888da79a930d8af0feb1dfb9c88cf2083f9eba60';
// Construct headers with authentication
$headers = array(
'Authorization' => 'Basic ' . base64_encode($consumer_key . ':' . $consumer_secret),
);
// Send a GET request
$response = wp_remote_get($url, array(
'headers' => $headers,
));
// Handle the JSON response
if (is_array($response) && !is_wp_error($response)) {
$body = wp_remote_retrieve_body($response);
$product_data = json_decode($body, true);
if ($product_data) {
foreach ($product_data as $product) {
echo 'Product ID: ' . $product['id'] . '
'; echo 'Product Name: ' . $product['name'] . '
'; echo 'Product Price: ' . $product['price'] . '
'; echo str_repeat('=', 40) . '
'; } } else { echo 'Failed to decode JSON response.'; } } else { echo 'Failed to fetch products. Error: ' . wp_remote_retrieve_response_message($response); }
'; echo 'Product Name: ' . $product['name'] . '
'; echo 'Product Price: ' . $product['price'] . '
'; echo str_repeat('=', 40) . '
'; } } else { echo 'Failed to decode JSON response.'; } } else { echo 'Failed to fetch products. Error: ' . wp_remote_retrieve_response_message($response); }