Home arrow PHP arrow Page 2 - Determine Link Relevance and Unique Class C IP using Yahoo Links API

Determine the Quality and Relevance of Inbound Links - PHP

The Yahoo Site Explorer Inbound Links API comes in handy for a variety of purposes. You can get all sorts of data from it using PHP, from counting your backlinks to analyzing where they're coming from. This article will show you how to build a backlink checker tool that can do this and more.

  1. Determine Link Relevance and Unique Class C IP using Yahoo Links API
  2. Determine the Quality and Relevance of Inbound Links
  3. Final Project Source Code and Testing
By: Codex-M
Rating: starstarstarstarstar / 2
August 18, 2010

print this article



This is trickier to do. However, the strategy is simple. Yahoo Links API provides a title tag of the inbound link pages. Since a title tag basically tells us what the page is all about, you can analyze the keywords contained in the title tag and then return statistics to the user to provide information on whether the inbound links to the website are related. The code to be added to original script is as follows:

//Extract the title tag from the Yahoo Links API array
//This is placed below the previous code to extract the URL which is:
//$myurl= $display1[$x]['Url'];

$mytitletag = $display1[$x]['Title'];

//You also need to assign the title tag to an array.
//This is placed at the last section just below this line:
//$domainarray[]=$domain; and before $x++
//This $titlearray[] contains all the title tag of all inbound link
//pages to the website

$titlearray[] = $mytitletag;

//Now since there are inbound link pages that comes from the same //domain, hence also contains the same title tag, you need to filter
//unique title tag from the array. This code is placed just outside the //while loop: while ($x < $count) {
//And just before:

$uniquetitletags = array_unique($titlearray);

//Start of link relevance analysis

//Reset array

echo '---------------------------------------------------';

echo '<br />';


echo '<br />';

echo '---------------------------------------------------';
echo '<br />';

echo '<br />';

//A short explanation about the link relevance analysis strategy

echo 'The relevance of your backlinks are computed based on the title tag of your backlinking pages. These title tag are important because it tells us what the backlink page is all about. The keywords from the title tag are then extracted and analyzed.';

echo '<br />';

echo 'If these keyword lists that is sorted by percentages MATCHES with your domain or website topic or niche, then congratulations; your backlinks are relevant to your website.<br />';

echo '<br />';

//Combine all words inside the unique title tags array to make it as
//one sentence for the analysis

$sentenceforanalysis= implode(" ",$uniquetitletags);

//Compute the keyword occurrence percentage

//Parts of the code is taken from http://bit.ly/5egil, authored by Tom
//str_word_count($str,1) - returns an array containing all the words
//found inside the string

$words = str_word_count(strtolower($sentenceforanalysis),1);

//Count the number of words

$numWords = count($words);

//array_count_values() returns an array using the values of the input
//array as keys and their frequency in input as values.

$word_count = (array_count_values($words));

//sort the results


//stopwords PHP array by Armand Brahaj found here:
//It is important to exclude the stop words from the analysis because
//they are not vital for relevance computations
//the script for stopwordslist.php can be found here:
//you need to change the path of the PHP include to reflect your own
//file path

include '/opt/lampp/htdocs/backlinkcount/stopwordslist.php';

//now that the stopwords array is in placed
//you need to check if the keywords in the title tag are not stopwords
//first define the $stopwordsarray which will contain the stopwords //found in the title tag keywords

$stopwordarray= array();

//next is to loop through the array

foreach ($word_count as $key=>$val) {

//to count the number of stop words, first you need to gather all the stop words found in the keyword title tags according to //stopwordslist.php
//this is done using a PHP array and assigning the stop words to

//Also check if the word consist entirely of English alphabets, this
//will filter non-words in the title which are not important for //analysis

//Exluded also in the analysis are words that consist of less than 3
//characters which are not also important.
//if all of the above condition are true, the keywords are assigned to
//the $stopwordarray[]

if ((in_array($key,$stopwords)) || (!(ctype_alpha($key))) || (strlen($key) < 3 )) {

$stopwordarray[] = $key;



//count the stop words detected
 that contains in the $stopwordarray
//using PHP sizeof function

$stopwordcount = sizeof($stopwordarray);

//Compute the number of words without stop words
 and other excluded //words

$adjustednumWords = $numWords - $stopwordcount;

//Finally loop through the array again to display the relevance //statistics detail to the user

foreach ($word_count as $key=>$val) {

if ((!(in_array($key,$stopwords))) && (ctype_alpha($key)) && (strlen($key) > 2)) {

//it is NOT a STOP word; display these keywords to the user

//as well as the percent occurrences

    echo "<b>$key = $val</b>. Percent occurrence: ".number_format(($val/$adjustednumWords)*100)."%<br/>n";



>>> More PHP Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: