Adaptadores CMS
Guías de integración: WordPress, cualquier sitio, Next.js, Strapi
Empieza por las opciones sin código. El código de abajo es para equipos que quieren control total.
Opciones sin código
- WordPress: abre Integraciones, escribe la dirección de tu sitio y aprueba la conexión en WordPress. Los artículos que publiques aparecen en tu sitio con portada, categorías y descripción SEO.
- Cualquier otro sitio (HTML estático, Webflow, Wix y similares): activa “Cualquier otro sitio web” en Integraciones y pega el fragmento en la página de tu blog. Sin servidor ni almacenamiento.
Todos los adaptadores siguen el mismo patrón: verificar HMAC en article.ready, obtener el artículo completo desde Tenant API v1 y hacer upsert en su CMS. Los borradores están disponibles de inmediato. Usted decide cuándo publicar.
Para desarrolladores: webhook y API
- Cree clave API y URL de webhook en Integraciones de GrowthDailySeo
- Exponga un endpoint POST y verifique X-GrowthDaily-Signature
- En article.ready, GET /api/v1/sites/{siteId}/posts/{slug}
- Haga upsert de contentHtml, seo y faqJsonLd. Publique según su calendario
Consulte también: Webhooks · Referencia API
Los webhooks solo avisan borradores nuevos. Pagina GET /posts una vez y luego updatedAfter. Igual que la sección de backfill de la referencia API.
Adaptadores por stack
Copie, adapte variables de entorno y nombres de tabla, despliegue.
Lo más fácil: conecta WordPress desde Integraciones, sin código. Usa el código del plugin de abajo solo si quieres controlar tú la sincronización.
Variables de entorno
# wp-config.php or server env
define('GROWTHDAILY_API_BASE', 'https://app.growthdailyseo.com');
define('GROWTHDAILY_API_KEY', 'fig_live_...');
define('GROWTHDAILY_WEBHOOK_SECRET', 'whsec_...');
define('GROWTHDAILY_SITE_ID', 'your-site-uuid');
// Tenant IndexNow — key file lives on YOUR WordPress domain (not GrowthDailySeo)
define('INDEXNOW_KEY', 'your-random-indexnow-key'); // also set in GrowthDailySeo niche_json.seo.indexnowKeyEndpoint de webhook
<?php
// wp-content/mu-plugins/growthdaily-webhook.php
add_action('rest_api_init', function () {
register_rest_route('growthdaily/v1', '/webhook', [
'methods' => 'POST',
'callback' => 'growthdaily_handle_webhook',
'permission_callback' => '__return_true',
]);
});
function growthdaily_handle_webhook(WP_REST_Request $request) {
$raw = $request->get_body();
$ts = $request->get_header('x-growthdaily-timestamp') ?: $request->get_header('x-figrush-timestamp') ?: '';
$sig = $request->get_header('x-growthdaily-signature') ?: $request->get_header('x-figrush-signature') ?: '';
$expected = hash_hmac('sha256', $ts . '.' . $raw, GROWTHDAILY_WEBHOOK_SECRET);
if (!hash_equals($expected, $sig)) {
return new WP_Error('invalid_signature', 'Invalid signature', ['status' => 401]);
}
$event = json_decode($raw, true);
if (($event['event'] ?? '') === 'article.ready') {
growthdaily_sync_post($event['siteId'], $event['slug']);
wp_remote_post(GROWTHDAILY_API_BASE . '/api/v1/sites/' . $event['siteId'] . '/posts/' . rawurlencode($event['slug']) . '/publish', [
'headers' => ['Authorization' => 'Bearer ' . GROWTHDAILY_API_KEY],
'timeout' => 15,
]);
}
return ['ok' => true];
}Función de sincronización (fetch + upsert)
function growthdaily_sync_post(string $site_id, string $slug): void {
$url = GROWTHDAILY_API_BASE . "/api/v1/sites/{$site_id}/posts/{$slug}";
$response = wp_remote_get($url, [
'headers' => ['Authorization' => 'Bearer ' . GROWTHDAILY_API_KEY],
'timeout' => 30,
]);
if (is_wp_error($response)) return;
$post = json_decode(wp_remote_retrieve_body($response), true);
if (empty($post['slug'])) return;
$existing = get_page_by_path($post['slug'], OBJECT, 'post');
$post_id = wp_insert_post([
'ID' => $existing ? $existing->ID : 0,
'post_title' => $post['title'],
'post_excerpt' => $post['excerpt'] ?? '',
'post_content' => $post['contentHtml'],
'post_status' => ($post['status'] ?? 'draft') === 'published' ? 'publish' : 'draft',
'post_name' => $post['slug'],
]);
if (!empty($post['seo']['ogTitle'])) {
update_post_meta($post_id, '_yoast_wpseo_title', $post['seo']['ogTitle']);
}
if (!empty($post['seo']['metaDescription'])) {
update_post_meta($post_id, '_yoast_wpseo_metadesc', $post['seo']['metaDescription']);
}
if (!empty($post['faqJsonLd'])) {
update_post_meta($post_id, '_growthdaily_faq_jsonld', wp_json_encode($post['faqJsonLd']));
}
if (!empty($post['schemaBundle'])) {
update_post_meta($post_id, '_growthdaily_schema_bundle', wp_json_encode($post['schemaBundle']));
}
}Renderizado y relleno
// Point webhook URL in GrowthDailySeo Integrations to:
// https://your-site.com/wp-json/growthdaily/v1/webhook
// Theme template — output Article + Breadcrumb + FAQ JSON-LD
function growthdaily_render_schema_bundle(int $post_id): void {
$raw = get_post_meta($post_id, '_growthdaily_schema_bundle', true);
if (!$raw) return;
$bundle = json_decode($raw, true);
if (!is_array($bundle)) return;
foreach (['article', 'breadcrumb', 'faq'] as $key) {
if (empty($bundle[$key])) continue;
echo '<script type="application/ld+json">' . wp_json_encode($bundle[$key]) . '</script>';
}
}
add_action('wp_head', function () {
if (is_singular('post')) growthdaily_render_schema_bundle(get_the_ID());
});
// Optional: nightly backfill for missed webhooks
add_action('growthdaily_daily_sync', function () {
$url = GROWTHDAILY_API_BASE . '/api/v1/sites/' . GROWTHDAILY_SITE_ID . '/posts?pageSize=50';
$response = wp_remote_get($url, [
'headers' => ['Authorization' => 'Bearer ' . GROWTHDAILY_API_KEY],
]);
$items = json_decode(wp_remote_retrieve_body($response), true)['items'] ?? [];
foreach ($items as $item) {
growthdaily_sync_post(GROWTHDAILY_SITE_ID, $item['slug']);
}
});
if (!wp_next_scheduled('growthdaily_daily_sync')) {
wp_schedule_event(time(), 'daily', 'growthdaily_daily_sync');
}Páginas generadas y llms.txt
// Fetch a generated page spec (path without leading slash)
function growthdaily_fetch_page($path) {
$encoded = rawurlencode(ltrim($path, '/'));
$url = GROWTHDAILY_API_BASE . '/api/v1/sites/' . GROWTHDAILY_SITE_ID . '/pages/' . $encoded;
$response = wp_remote_get($url, [
'headers' => ['Authorization' => 'Bearer ' . GROWTHDAILY_API_KEY],
]);
return json_decode(wp_remote_retrieve_body($response), true);
}
// Proxy llms.txt onto your domain
function growthdaily_llms_txt(): string {
$url = GROWTHDAILY_API_BASE . '/api/v1/sites/' . GROWTHDAILY_SITE_ID . '/llms.txt';
$response = wp_remote_get($url, [
'headers' => ['Authorization' => 'Bearer ' . GROWTHDAILY_API_KEY],
'timeout' => 20,
]);
return is_wp_error($response) ? '' : wp_remote_retrieve_body($response);
}Feed del sitemap
// Dynamic sitemap feed
function growthdaily_fetch_sitemap(): string {
$url = GROWTHDAILY_API_BASE . '/api/v1/sites/' . GROWTHDAILY_SITE_ID . '/sitemap.xml';
$response = wp_remote_get($url, [
'headers' => ['Authorization' => 'Bearer ' . GROWTHDAILY_API_KEY],
'timeout' => 30,
]);
return is_wp_error($response) ? '' : wp_remote_retrieve_body($response);
}
// Rewrite rule or template_redirect to serve XML at /sitemap-growthdaily.xmlAviso a IndexNow
// Upload {INDEXNOW_KEY}.txt to WordPress web root (ABSPATH) — content = key string
// e.g. https://www.your-domain.com/a1b2c3.txt contains "a1b2c3"
function growthdaily_indexnow_ping(string $url): void {
if (!defined('INDEXNOW_KEY')) return;
wp_remote_post('https://api.indexnow.org/indexnow', [
'headers' => ['Content-Type' => 'application/json'],
'body' => wp_json_encode([
'host' => wp_parse_url(home_url(), PHP_URL_HOST),
'key' => INDEXNOW_KEY,
'keyLocation' => home_url('/' . INDEXNOW_KEY . '.txt'),
'urlList' => [$url],
]),
]);
}