Analyzing the Back Link Count from Unique Domains using Yahoo Inbound Links API

Welcome to the conclusion of a three-part series that shows you how to count the back links to your web site from unique domains using the Yahoo Inbound Links API. In the second part you learned how to pass the form variables to PHP using AJAX, process the web form input using PHP, and finally validate the root domain name URL using PHP. In this part, we discuss the details of the Yahoo API PHP script process.

Formulate a Request to Yahoo Inlinks API

 

It is a wise programming strategy to report all errors, so the first line before communicating to the API is this one:

 

error_reporting(E_ALL);

 

To formulate the request, we need values for the following API variables, which we can obtain from user form input processing discussed in part two:

 

1.) appid = OUiTAC3V35FlhDKeOScqpmw42RTY8B4BI8VUI7kB6sczVWIjJxr45D3QRWcNOPeQ–

 

You should have your own API ID that can be obtained here: http://developer.yahoo.com/search/siteexplorer/

 

2.) query= http://www.thisisyourrootdomainurl.com

 

Query variables are the root domain URL.

 

3.) omit_inlinks=domain

 

This is the default, and cannot be obtained from form processing. Equating it to “domain” means that the API will exclude inlinks data from the same domain as the queried domain. This will ensure that all back links reported come from outside the domain.

 

4.) entire_site=userinputoptions

 

Possible values include 1 to get back link results pointing to the entire site, or “” (empty), to get back link results pointing only to that specific URL.

 

5.) results=100

 

As discussed in the first two parts, the Yahoo API can only provide a maximum of 100 back link URLs. So we say that we want the result variable to return the maximum number (100).

 

6.) output=php

 

This means that the Yahoo API will format the output in a serialized PHP array. You can learn about serialized PHP arrays in greater detail at the link.: 

 

In PHP, the request URL to API in GET statements structure will be formulated as follows (incorporating all six API variables discussed above as a single GET request):

 

$request = ‘http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid= OUiTAC3V35FlhDKeOScqpmw42RTY8B4BI8VUI7kB6sczVWIjJxr45D3QRWcNOPeQ–&query=’.$domainurl.’&results=100&output=php&omit_inlinks= domain&entire_site=’.$options;

 

{mospagebreak title=Get API results and do preliminary data processing}

 

To get the response, we will use the file_get_contents function for simplicity, although other options are possible (like cURL, etc).

 

$response = file_get_contents($request);

 

if ($response === false) {

die(‘The request fails.’);

}

 

$unserialized = unserialize($response);

$display= $unserialized['ResultSet'];

$display1=$display['Result'];

$totalbacklinksnotunique=$display['totalResultsAvailable'];

 

Principles of the above basic statements are discussed here:

 

http://www.devshed.com/c/a/PHP/Using-the-Yahoo-Site-Explorer-Inbound-Links-API/

 

http://www.devshed.com/c/a/PHP/Getting-Data-from-Yahoo-Site-Explorer-Inbound-Links-API-using-PHP/

 

Since it is serialized, it will be converted to an unserialized data format, and the "totalResultsAvailable: is the total back link quantity pointing to either the entire domain or to a specific URL depending on the value set by "options" on the API request URL.

 

Loop the results and extract the domain name only

 

The strategy is to store the URLs in an array in the loop process and initialize the count to 0. The size of the array which will be used to terminate the loop process is also important:

 

$domainarray = array();

$x=0;

$count= sizeof($display1);

 

And the entire loop statements (discussion on PHP comments):

 

while ($x < $count) {

 

//store URLs from unserialized PHP array to myurl variable

 

$myurl= $display1[$x]['Url'];

 

//after storing the variable, do string manipulation to get domain name only

//example http://www.domainurl.com/test1.htm will now become domainurl.com

//This is a 9 step process.

 

$httpprotocolcheck =substr($myurl, 0, 7);

$httpsprotocolcheck =substr($myurl, 0, 8);

if ($httpprotocolcheck=="http://") {

 

//Step1: http version

 

$backlinkprotocol= "http://";

}

if ($httpsprotocolcheck=="https://") {

 

//Step 2: https version

 

$backlinkprotocol= "https://";

}

 

//Step 3: Assign offset for each protocol

 

if ($backlinkprotocol=="http://") {

$offsetcount= 7;

}

if ($backlinkprotocol=="https://") {

$offsetcount= 8;

}

 

//Step 4: Determine 1st occurrence of trailing slash after the protocol

 

$positiontrailingslash = strpos($myurl, ‘/’, $offsetcount);

$actualposition = $positiontrailingslash – $offsetcount;

 

//Step 5: Extract domain portion for test of non-www version

 

$domainportion = substr($myurl, $offsetcount, $actualposition);

 

//Step 6: Count the number of dots, if only one dot found it is non-www version

 

$dotcount= substr_count($domainportion, ‘.’);

if ($dotcount==1) {

$domain = $domainportion;

}

if (($dotcount==2) || ($dotcount==3)) {

 

//Step 7: This is NOT a non-www version, find position of 1st dot

 

$firstdotposition = strpos($myurl, ‘.’);

$firstdotrealoffset= $firstdotposition +1;

 

//Step 8: Find position of 2nd dot, adjustments for TLDs like .co.uk is included

 

$seconddotposition = strpos($myurl, ‘.’, $firstdotrealoffset);

$differenceofdots= $seconddotposition – $firstdotposition -1;

if ($differenceofdots=="2") {

$domain = $domainportion;

}

else {

$firstdotoffset = $firstdotposition + 1;

$trailingoffset = $positiontrailingslash – $firstdotposition -1;

$domain = substr($myurl,$firstdotoffset, $trailingoffset);

}

}

if ($dotcount==3) {

$firstdotoffset = $firstdotposition + 1;

$trailingoffset = $positiontrailingslash – $firstdotposition -1;

$domain = substr($myurl,$firstdotoffset, $trailingoffset);

}

 

//Step 9: Finally, after the string manipulation, store only the domain name to the array

 

$domainarray[]=$domain;

 

//after storing the values, increment the loop by 1.

 

$x++;

}

 

{mospagebreak title=Filter unique domains and display in browser}

 

Now that all domains are stored in the $domainarray array, you will need to filter unique domains using array_unique PHP function. All unique domains will then be assigned to a new variable that we call $uniquedomains:

 

$uniquedomains=array_unique($domainarray);

 

We will need to display these unique domains in the browser. To do this, we will loop:

 

while (list($key, $value) = each($uniquedomains)) {

echo $value;

echo ‘<br />';

}

 

Since the Yahoo Site Explorer API can only provide a maximum of 100 results for analysis, we will estimate the real count of unique domain back links. First, we will need to count the number of unique domains obtained from the analysis:

 

$uniqueinsample = sizeof($uniquedomains);

 

Then the $count variable holds the actual number of samples provided by the API (maximum 100). $totalbackliksnotunique holds the value for the total back links pointing to the domain (not unique).

 

$uniquebacklinkstotal= ($uniqueinsample/$count)*($totalbacklinksnotunique);

 

Therefore the overall remaining PHP script to output the unique back link results back to the browser is as follows:

 

$uniquedomains=array_unique($domainarray);

echo ‘—————————————–‘;

echo ‘<br />';

echo ‘|THIS IS YOUR LINK POPULARITY STATISTICS:|';

echo ‘<br />';

echo ‘—————————————–‘;

echo ‘<br />';

 

$uniqueinsample = sizeof($uniquedomains);

$uniquebacklinkstotal= ($uniqueinsample/$count)*($totalbacklinksnotunique);

 

if ($options==1) {

$conditions=’ENTIRE SITE';

}

if ($options==”) {

$conditions=’THAT SPECIFIC URL ONLY';

}

 

echo "<b>ESTIMATED TOTAL BACKLINKS FROM UNIQUE DOMAINS POINTING TO $conditions:&nbsp;".round($uniquebacklinkstotal).'</b>';

echo ‘<br /><br />';

echo "These are the unique domains of the total $totalbacklinksnotunique backlinks pointing to $conditions.";

echo ‘<br />';

echo "In a sample gathered, you have $uniqueinsample backlinks from unique domains OUT of $count SAMPLES GATHERED";

echo ‘<br />';

echo ‘<a href="/countuniquelinks/countuniquelinks.php"><b>CLICK HERE TO USE THE TOOL AGAIN</b></a>';

echo ‘<br /><br />';

echo ‘Below are the sample unique back linking domains:(100 domains maximum)';

echo ‘<br /><br />';

while (list($key, $value) = each($uniquedomains)) {

echo $value;

echo ‘<br />';

}

echo ‘<br />';

echo ‘<br />';

echo ‘Note: The above domains might belong to the same Class C IP address.';

echo ‘<br />';

echo ‘<br />';

echo ‘<a href="/countuniquelinks/countuniquelinks.php"><b>CLICK HERE TO USE THE TOOL AGAIN</b></a>';

$_SESSION = array ();

session_destroy ();

 

?>

 

{mospagebreak title=Running and performing a test implementation}

 

If you comply with the requirements stated in part one, particularly the PHP requirements, running this application with your server will not be that difficult.

 

You can see an actual working project at the link. You can also check the “Download source code” link, where you can download the .zip file of the entire source code discussed in this tutorial.

 

To implement, download it first, then unzip the folder. Upload the folder to your server root directory or htdocs directory if you are using XAMPP. Then, using a browser, enter this in the address bar:

 

http://www.thisisyourdomain.com/countuniquelinks/countuniquelinks.php

 

Or in XAMPP:

 

http://localhost/countuniquelinks/countuniquelinks.php

 

Note: Do not forget to replace (in bold):

appid=xxxxxxyourapplicationidherexxxxxxx ,with your own Yahoo application ID, replace the text in bold and save to yahooapiajax.php before uploading to your server or running the application.

 

If you do not see any error, then enter a sample root domain URL, such as:

 

http://www.devshed.com

 

Check the radio button option: “Only to the homepage URL,” to see the back link data pointing to the http://www.devshed.com home page only. Finally, after entering the captcha, click “Submit” button.

 

Since the form uses AJAX, the results will be shown in the same URL. You should see a link popularity statistics report like the one below:

 

—————————————–

|THIS IS YOUR LINK POPULARITY STATISTICS:|

—————————————–

ESTIMATED TOTAL BACKLINKS FROM UNIQUE DOMAINS POINTING TO THAT SPECIFIC URL ONLY: 43744

 

These are the unique domains of the total 230230 backlinks pointing to THAT SPECIFIC URL ONLY.

In a sample gathered, you have 19 backlinks from unique domains OUT of 100 SAMPLES GATHERED

CLICK HERE TO USE THE TOOL AGAIN

 

Below are the sample unique backlinking domains:(100 domains maximum)

 

eweek.com

linuxfordevices.com

microsoft-watch.com

desktoplinux.com

pdfzone.com

publish.com

baselinemag.com

cioinsight.com

windowsfordevices.com

bigredspark.com

linux-watch.com

channelinsider.com

devsource.com

ziffdavisenterprise.com

deviceforge.com

tamu.edu

ileriseviye.org

unmatchlist.com

degreetutor.com

 

Interpreting the results

 

The above example shows that total amount of links pointing to the http://www.devshed.com home page is 230,230. This includes duplicated links (multiple links coming from the same domain). The Yahoo Site Explorer API provided 100 back link samples, and according to the analysis, 19 out of 100 are unique. Using these statistics, the estimated back links coming from unique domains is 43,744.

 

The tool also provides the list of sample unique domains linking to the devshed.com website. With this data, you can determine whether or not those back linking domains are relevant to your domain. If they are not related, and only a few unique domains link to the site, then you need to work hard to increase your link popularity using techniques such as link baiting and others to raise your visibility.

[gp-comments width="770" linklove="off" ]

chat sex hikayeleri Ensest hikaye