PHP Function for Reciprocal Linkback Checking
Tuesday 19th August 2008

A PHP function for reciprocal linkback checking, the function will check the supplied URL for a link back and can also validate whether or not the link has a nofollow tag which will prevent search engines from indexing the link or playing relevance to the linkback.
The function is especially useful if you run a link exchange and want to automatically validate each user is linking to your own web site before you link to their web site. You may also find the function useful for validating links in your own web site content, for example the function could be used to find typos or out-of-date links.
Usage

Simply use the following to check a URL and return the response to the variable, $reciprocal_linkback:
require "reciprocal_linkback.php";
$linkback = reciprocal_linkback("http://ionix.ltd.uk/",
"http://www.opencrypt.com");
Then setup the conditions as you require:
if ("$linkback"=="1") {
print "Link found";
} elseif ("$linkback"=="2") {
print "Unable to read URL";
} else {
print "Link not found";
}
To enable the 'nofollow' checking use the following code (note the addition of the ,1):
require "reciprocal_linkback.php";
$linkback = reciprocal_linkback("http://ionix.ltd.uk/",
"http://www.opencrypt.com", 1);
The three input flags are used as outlined below:
reciprocal_linkback("URL TO CHECK", "URL TO FIND",
"ENABLE NOFOLLOW CHECK");
- URL TO CHECK

This is the URL of the page where we are trying to find the link. Enter a full URL, e.g. http://www.locked-area.com/
A trailing slash or filename are not needed.

- URL TO FIND

This is the URL of the page the 'URL TO CHECK' should be linking to. Enter the URL you want to find, it is recommended you just check for your domain to reduce complication. e.g. http://ww.opencrypt.com
You can add a trailing slash or filename but this may reduce the reliability of the check.

- ENABLE NOFOLLOW CHECK

If enabled, the function will check if the link to 'URL TO FIND' contains a 'nofollow' tag, if this is present then search engines will not index the page and the linkback will not for example improve your pagerank. Set to '1' to enable, leave blank or set to '0' to disable.
Responses

1
Link was found successfully.
0
Link was not found, or nofollow check has failed.
2
Unable to read 'URL TO CHECK'.
License and Download

This code is Open Source and is released under the GNU General Public License.
We hope you find this code of use, if you use it in your projects we'd love to hear about it! And of course, if you have any questions please don't hesitate to post a comment and we will respond as soon as possible.
Syntax highlighting powered by JUSH
Share this article:
|
<- AJAX Tree Menu with PHP - Revisited
|
AJAX Calendar with PHP and mySQL ->
|
|