function xbz_buscar_produtos() {
$url = "https://fluxo-xbz.fluencemarketingdigital.workers.dev/?cnpj="
. get_option('xbz_cnpj')
. "&token="
. get_option('xbz_token');
$tentativas = 3;
$response = null;
for ($i = 0; $i < $tentativas; $i++) {
$response = wp_remote_get($url, [
'timeout' => 60,
'sslverify' => false
]);
if (!is_wp_error($response)) {
break;
}
sleep(2); // espera antes de tentar de novo
}
// 🔥 se falhou mesmo assim
if (is_wp_error($response)) {
update_option('xbz_last_log', 'Erro API (falha conexão)');
error_log('XBZ API ERROR: ' . $response->get_error_message());
return [];
}
$body = wp_remote_retrieve_body($response);
if (empty($body)) {
update_option('xbz_last_log', 'Erro API (resposta vazia)');
return [];
}
// 🔥 tenta normal
$data = json_decode($body, true);
// 🔥 fallback JSON duplo (sua API já teve isso)
if (is_string($data)) {
$data = json_decode($data, true);
}
if (!is_array($data)) {
update_option('xbz_last_log', 'Erro API (JSON inválido)');
error_log('XBZ JSON ERROR: ' . substr($body, 0, 200));
return [];
}
return $data;
}
Warning: Cannot modify header information - headers already sent by (output started at /home1/agen4023/mamutebrindes.com.br/wp-content/plugins/xbz-integration-fluence/includes/api.php:1) in /home1/agen4023/mamutebrindes.com.br/wp-includes/sitemaps/class-wp-sitemaps-renderer.php on line 126
https://mamutebrindes.com.br/wp-sitemap-posts-post-1.xmlhttps://mamutebrindes.com.br/wp-sitemap-posts-page-1.xmlhttps://mamutebrindes.com.br/wp-sitemap-posts-product-1.xmlhttps://mamutebrindes.com.br/wp-sitemap-posts-product-2.xmlhttps://mamutebrindes.com.br/wp-sitemap-taxonomies-category-1.xmlhttps://mamutebrindes.com.br/wp-sitemap-taxonomies-product_cat-1.xml