Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to calculate google backlinks using php

Tags:

php

i want to create my own tool for back-links calculation using PHP. is there any api to fetech the data for back links

like image 833
webkul Avatar asked May 01 '10 20:05

webkul


2 Answers

The full implementation in PHP would look something like this:

<?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.

EDIT: I've edited the link to return 8 results. For more, you'll have to parse the pages and loop through them with the start parameter. See the Class Reference for more information.

like image 152
Arda Xi Avatar answered Oct 23 '22 08:10

Arda Xi


Run a Google search with the URL prefixed by link: - for instance, link:www.mydomain.com.

While Google does provide a more specific backlink overview in their Webmaster Tools area (more info), I'm not sure they provide an external API for it.

like image 36
Amber Avatar answered Oct 23 '22 08:10

Amber