Skip to content

How to calculate google backlinks using php

jarmoluk / Pixabay

There are several ways to implement a calculation of the number of backlinks via PHP.

<?php
$domain = "example.com"; // Enter your domain here.

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&"
    . "q=link:".$domain;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $domain);
$body = curl_exec($ch);
curl_close($ch);

$json = json_decode($body);
$urls = array();
foreach($json->responseData->results as $result) // Loop through the objects in the result
    $urls[] = $result->unescapedUrl;             // and add the URL to the array.
?>

Basically you edit the domain variable at the top and it will fill the $urls array with unescaped URLs linking to the domain.

More

Dieser Beitrag hat 0 Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

An den Anfang scrollen