Skip to content

pear2/Services_Linkback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PEAR2 Services_Linkback

Pingback and webmention client and server implementation for PHP 5.3+.

The package provides a basic pingback+webmention server implementation that can be customized easily via callbacks.

Usage:

$srv = new \PEAR2\Services\Linkback\Server();
$srv->addCallback(new PingbackLogger());
$srv->run();
source URL
Remote URL that links to the local target URL
target URL
Local URL that gets linked by the source URL

The server provides 4 types of callbacks to modify its behaviour. Each callback needs to implement one of the four interfaces:

Verifies that the target URL exists in the local system. Useful to filter out pingbacks for non-existant URLs.

FIXME: Default implementation

Fetches the source URL for further verification. Used to determine if the source URL really exists.

Services_Pingback provides the Services\Linkback\Server\Callback\FetchSource callback class that is automatically registered with the server.

Verifies that the source URL content really links to the target URL. Used to filter out fake pingbacks that do not actually provide links.

Services_Pingback provides the Services\Linkback\Server\Callback\LinkExists callback class that is automatically registered with the server.

After all verifications have been done, the storage finally handles the pingback - it could e.g. log it to a file or a database.

Services_Pingback does not provide a default storage implementation; you have to write it yourself.

See what we can learn from http://www.acunetix.com/blog/web-security-zone/wordpress-pingback-vulnerability/

Tell someone that you linked to him:

$from = 'http://my-blog.example.org/somepost.html';
$to   = 'http://b.example.org/inspiration.html';
$lbc  = new \PEAR2\Services\Linkback\Client();
$lbc->send($from, $to);

You can adjust the HTTP_Request2 settings:

$req = $lbc->getRequest();
$req->setConfig(
    array(
        'ssl_verify_peer' => false,
        'ssl_verify_host' => false
    )
);
$lbc->setRequestTemplate($req);

And change the user agent header sent with the linkback requests:

$req = $lbc->getRequest();
$headers = $req->getHeaders();
$req->setHeader('user-agent', 'my blog engine');
$lbc->setRequestTemplate($req);

And a debug mode is available, too:

$lbc->setDebug(true);

This setting stores HTTP responses for later inspection.

Using composer:

$ composer require pear2/services_linkback

Services_Linkback was written by Christian Weiske and is licensed under the LGPLv3 or later.

Homepage
http://pear2.php.net/PEAR2_Services_Linkback
Bug tracker
https://github.com/pear2/Services_Linkback/issues
Documentation
The examples/ folder.
Packagist
https://packagist.org/packages/pear2/services_linkback
Unit test status

https://travis-ci.org/pear2/Services_Linkback

https://travis-ci.org/pear2/Services_Linkback.svg?branch=master