Voltar
Documentação

Integração Server-Side

Integre meta tags otimizadas do mySEOTop em qualquer plataforma. Todos os snippets são server-side — as tags são renderizadas no HTML antes de chegar ao browser, garantindo que o Google indexe corretamente.

Por que Server-Side?

✅ Server-Side (correto)

  • • Google indexa as meta tags
  • • OG tags funcionam em redes sociais
  • • LLMs (ChatGPT) leem as tags
  • • Zero impacto na performance
  • • Funciona sem JavaScript

❌ Client-Side (problemático)

  • • Google pode NÃO indexar
  • • OG tags NÃO funcionam (compartilhamento)
  • • LLMs NÃO veem as tags
  • • Delay de carregamento
  • • Depende de JavaScript

Como funciona

1

Gere as tags

No painel mySEOTop, analise seu site e aprove as meta tags geradas pela IA.

2

Pegue sua API Key

Em Meus Sites → selecione o site → copie a API Key.

3

Cole o snippet

Escolha sua linguagem abaixo e cole o snippet no seu projeto. Pronto!

API Reference

GEThttps://www.myseotop.com.br/api/v1/tags?url=/sua-pagina

Header: X-API-Key: msk_live_...

Parâmetro: url — path da página (ex: /blog/meu-post ou URL completa)

Resposta: JSON com tags (objeto) e html (string com tags prontas)

Exemplo de resposta:

{
  "found": true,
  "url": "/blog/meu-post",
  "seo_score": 85,
  "tags": {
    "title": "Título otimizado — Meu Site",
    "description": "Meta description otimizada...",
    "og_title": "Título para redes sociais",
    "og_description": "Descrição para compartilhamento",
    "canonical": "https://meusite.com/blog/meu-post",
    "robots": "index, follow"
  },
  "html": "<title>Título otimizado</title>\n<meta name=\"description\" ..."
}

📦 Snippets por linguagem

PHP puro (file_get_contents)

Snippet simples para qualquer site PHP. Busca tags da API e injeta no <head> com cache de 1 hora.

Requisitos: PHP 7.4+, allow_url_fopen habilitado
myseotop.php
<?php
/**
 * mySEOTop — Server-Side Meta Tags
 * Inclua este arquivo no <head> do seu site
 * 
 * Uso: <?php include 'myseotop.php'; ?>
 */

define('MYSEOTOP_API_KEY', 'msk_live_SUA_API_KEY_AQUI');
define('MYSEOTOP_API_URL', 'https://www.myseotop.com.br/api/v1/tags');
define('MYSEOTOP_CACHE_DIR', __DIR__ . '/cache/myseotop/');
define('MYSEOTOP_CACHE_TIME', 3600); // 1 hora

function myseotop_get_tags() {
    $current_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
    $cache_file = MYSEOTOP_CACHE_DIR . md5($current_path) . '.html';
    
    // Criar diretório de cache se não existir
    if (!is_dir(MYSEOTOP_CACHE_DIR)) {
        mkdir(MYSEOTOP_CACHE_DIR, 0755, true);
    }
    
    // Verificar cache
    if (file_exists($cache_file) && (time() - filemtime($cache_file) < MYSEOTOP_CACHE_TIME)) {
        return file_get_contents($cache_file);
    }
    
    // Buscar da API
    $url = MYSEOTOP_API_URL . '?url=' . urlencode($current_path);
    
    $context = stream_context_create([
        'http' => [
            'method' => 'GET',
            'header' => "X-API-Key: " . MYSEOTOP_API_KEY . "\r\n" .
                        "Content-Type: application/json\r\n",
            'timeout' => 5,
            'ignore_errors' => true,
        ],
    ]);
    
    $response = @file_get_contents($url, false, $context);
    
    if ($response === false) {
        return '<!-- mySEOTop: API indisponível -->';
    }
    
    $data = json_decode($response, true);
    
    if (!isset($data['found']) || !$data['found'] || empty($data['html'])) {
        return '<!-- mySEOTop: Página não encontrada na API -->';
    }
    
    $html = $data['html'];
    
    // Salvar em cache
    file_put_contents($cache_file, $html);
    
    return $html;
}

// Injetar tags
echo "\n<!-- mySEOTop AI Tags (server-side) -->\n";
echo myseotop_get_tags();
echo "\n<!-- /mySEOTop AI Tags -->\n";
?>
uso-no-head.php
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <!-- mySEOTop tags (server-side) -->
    <?php include __DIR__ . '/myseotop.php'; ?>
    
    <!-- Seus outros CSS/JS -->
    <link rel="stylesheet" href="/style.css">
</head>
<body>
    <!-- Conteúdo -->
</body>
</html>

💡 O cache salva em arquivo local para não chamar a API a cada page view. Tempo de cache: 1 hora. Altere CACHE_TIME para ajustar.

Comece em 5 minutos

Crie sua conta, analise seu site, aprove as tags e integre com o snippet da sua linguagem.