¿Problemas con tu sitio web? Estamos aquí para ayudarte 24/7

Google SERP Rank tracker PHP Script (código incluido)

4.7 / 5

Antes de usar el script PHP de verificación de SERP de Google

El siguiente script PHP de verificación de SERP funciona con la API de búsqueda personalizada de Google. Para utilizar el script con la API, deberás seguir estos pasos:

  1. Activa la API de búsqueda personalizada de Google y cree credenciales yendo aquí: https://console.developers.google.com
  2. Crea un motor de búsqueda personalizado de Google aquí: https://cse.google.com/cse/all
  3. Puedes probar que tus credenciales y el motor de búsqueda personalizado funciona aquí: https://developers.google.com/apis-explorer/?hl=en_US#p/customsearch/v1/search.cse.list

Si no funciona, asegúrate que estás creando una clave de API nueva, en el dashboard del proyecto de console.google.

Algunas configuraciones de PHP

Asegúrate de que allow_url_fopen = activado, si no puedes sustituirlo por curl o probar otros métodos.

El código del script:

<?
$GOOGLE_API_KEY = 'Insert Your Google Custom Search API Key';
$GOOGLE_CSE_CX = 'Insert Your Search Engine ID';

//the search query
$query = urlencode($_POST["query"]);
//the domain for which to show the ranking
$domain = $_POST["domain"];

//gl - google host - https://developers.google.com/custom-search/docs/xml_results_appendices#countryCodes
//hl - user language - https://developers.google.com/custom-search/docs/xml_results_appendices#interfaceLanguages
//pages - how many pages should the search extend

$pages = isset($_POST["pages"])?$_POST["pages"]:1;
$gl = isset($_POST["gl"])?$_POST["gl"]:"us";
$hl = isset($_POST["hl"])?$_POST["hl"]:"en";

$found = false;
echo "<ul>";
for ($page = 1;$page <= $pages && $found == false;$page++){
$apiurl = sprintf('https://www.googleapis.com/customsearch/v1?q=%s&cx=%s&key=%s&hl=%s&gl=%s&start=%d',$query,$GOOGLE_CSE_CX,$GOOGLE_API_KEY,$hl,$gl,($page-1)*10+1);
$json = file_get_contents($apiurl);
$obj = json_decode($json);

foreach ($obj->items as $idx=>$item) {
if (strpos($item->link, $domain) ){
$found = true;
echo "<li>";
} else{
echo "<li class='other'>";
}
echo "<span class='rank'>".($idx + ($page-1)*10 +1)."</span>";
echo "<span class='title'>".$item->htmlTitle."</span>";
echo "<span class='link'>".$item->link."<small>▼</small></span>";
echo "<span class='snippet'>".$item->htmlSnippet."</span>";
echo "</li>";

}
}
if ($found !== true){
echo "<li>";
echo "<span class='title'>".$domain." not found</span>";
echo "</li>";
}
echo "</ul>";

Script compartido por coding-dude.com, aquí puedes encontrar a parte del script una interfaz para probarlo, previa descarga. http://www.coding-dude.com/wp/php/serp-checker-php-script/

1/5

Php Ninja - Mantenimiento Web

Somos un equipo de programadores web expertos en PHP, WordPress y Prestashop, con más de 15 años de experiencia, 100% especializados en mantenimiento y arreglos, lo que nos permite ofrecer un servicio muy completo y único de mantenimiento y reparación de páginas web. Conoce más sobre nosotros

Primeros pasos

El equipo técnico está a la espera de conocer tu solicitud para empezar a trabajar. Regístrate para contratar nuestros servicios, asignar tareas a programadores y recibir asistencia.

Empezar
Reservar una llamada con nuestros asesores

    Contacta sin compromiso








    *Tus datos están seguros porque cumplimos con el RGPD (Reglamento General de Protección de Datos

    • Responsable: Ayesa Digital SLU
    • Finalidad: Responderte al correo que vas a enviar.
    • Legitimación: Consentimiento.
    • Destinatarios: tus datos de contacto se almacenarán en nuestra base de datos.
    • Derechos: Cambios, rectificaciones, borrados, escríbenos a administracion@phpninja.es

    Puedes consultar la información adicional y detallada sobre Protección de Datos en .

    Workcation

    Muy profesionales. Resuelven rápido e informan en todo momento del estado del trabajo. 100% recomendado.

    Conchetta Alonso

    CEO at Workcation

    4.7/5 Leer opiniones sobre Php Ninja en Google reviews

    Programadores con más de 10 años de experiencia especialistas en
    PHP Logo
    Javascript Logo
    Apache Logo
    WordPress Logo
    Prestashop Logo
    Drupal Logo
    MYSQL Logo
    Linux Logo

    HTML - PHP - JS - CSS - MYSQL - WORDPRESS - PRESTASHOP

    Opiniones

    ¿Qué han dicho nuestros clientes?

    • I had a problem with the WordPress website blocking access. I contacted them and they very quickly gave me a quote, with an immediate execution time. I couldn't be happier with the choice, especially when I had no direct references from the company. The solution was clean, professional and without data loss.

      Daniel Martin Avatar Daniel Martin
      22/04/2024

      Very happy with the service, whenever I have a problem they solve it quickly and efficiently! And the treatment is excellent. A hug!

      Sara Teller Avatar Sara Teller
      05/10/2023

      I had a complicated problem with my website and I am very happy with the result, since they gave me a pack of hours, and it was solved quickly and at a very reasonable price. Since they had a little time left, they still fixed a couple of things that needed to be touched up. I would repeat with them without hesitation. Super professionals in my point of view.

      Natural Channel Avatar Natural Channel
      24/10/2023
    • Nuestra web se nos bloqueó y contactamos con Ninja que nos resolvió el problema en muy poco tiempo. Confiamos que sigan siempre ahí y les encargaremos mas trabajos, esta vez esperamos que sin urgencias.

      Susan Wolf Avatar Susan Wolf
      22/04/2024

      Beto did a great job with optimizing our WordPress website! It was very slow in the beginning, but thanks to his efforts now runs really fast and smoothly. Outstanding professional, great communication & superb results! We’ll definitely hire him again for future projects. Thanks Beto!

      Verena Nyc Avatar Verena Nyc
      19/11/2019

      The company made a very good work for me. Very professional team, rapidly done, and we had a good feedback during the duties. The team has a high expertise with php. I do recommend them.

      Vicente Celada Gonzalez Avatar Vicente Celada Gonzalez
      19/06/2021
    • Fast, effective and humane!

      Robert Hunter Avatar Robert Hunter
      29/02/2024

      Our website was blocked and we contacted Ninja who solved the problem in a very short time. We trust that they will always remain there and we will assign them more work, this time we hope without emergencies.

      Susan Wolf Avatar Susan Wolf
      22/04/2024

      Very professional, totally recommended.

      joaquin sariñena Avatar joaquin sariñena
      01/03/2024
    • Very positive experience due to professionalism, knowledge and relationship with the client.

      Francisco Bargiela Avatar Francisco Bargiela
      21/03/2024
    ¿Necesitas asistencia técnica?

    Te respondemos rápidamente. Sin compromiso

      Habla con un programador
    Php Ninja
    icono whatsapp programador web
    Inicio Equipo Servicios Contacto