Link Exchange Verification

I made a link exchange with another site. After 3 days, the site deleted my link.

Is there a simple php script that helps me control the link exchange and notify me if my link has been deleted?

I need it as simple as possible, not an entire ad. system manager.

+3
source share
2 answers

If you know the URL of the webpage on which your ad exists (link), you can use the Simple HTML DOM Parser to get all the links of this webpage in an array, and then use the php in_array function to check if link in this array or not. You can run this script on a daily basis with crontab .

// Create DOM from URL
$html = file_get_html('http://www.example.com/');

// Find all links 
$allLinks = array();
foreach($html->find('a') as $element) {
    $allLinks[] =  $element->href;
}

// Check your link. 
$adLink = "http://www.mylink.com";
if ( in_array($adLink , $allLinks ) ) {
    echo "My link exists.";
} else {
    echo "My link is removed.";
}
+4
source

Technically there is no way to find out if someone has a website link to yours if you don’t have traffic from your website or if you are looking at their website.

Best would be:

A script that is written every time they refer to your image. It's simple enough by mixing PHP and .htaccess

.htaccess:

RewriteRule path/to/myImage.jpg path/to/myScript.php

myScript.php:

/* Record (database, file, or however) that they accessed */
header("Content-type: image/jpeg");
echo file_get_contents("path/to/myImage.jpg");

script, - X // HTML . , script. crontab

myScript.php:

$html = file_get_contents("http://www.theirsite.com");
if(strpos($html, 'path/to/myImage.jpg') !== FALSE)
    /* Happiness */
else
    /* ALERT! */
0

Source: https://habr.com/ru/post/1768094/


All Articles