PHP code example of pear / net_webfinger
1. Go to this page and download the library: Download pear/net_webfinger library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pear / net_webfinger example snippets
$wf = new Net_WebFinger();
$react = $wf->finger('[email protected] ');
if ($react->error !== null) {
echo "Error when fetching " . $react->url . "\n";
echo "Error: " . $react->error->getMessage() . "\n";
if ($react->error->getPrevious()) {
echo "Underlying error: "
. $react->error->getPrevious()->getMessage() . "\n";
}
}
$wf = new Net_WebFinger();
$react = $wf->finger('[email protected] ');
if ($react->error) {
echo 'There was an error: ' . $react->error->getMessage() . "\n";
}
$openIdProvider = $react->get('http://specs.openid.net/auth/2.0/provider');
if ($openIdProvider !== null) {
echo 'OpenID provider found: ' . $openIdProvider . "\n";
}
$wf = new Net_WebFinger();
$react = $wf->finger('[email protected] ');
if ($react->error) {
echo 'There was an error: ' . $react->error->getMessage() . "\n";
}
if ($react->openid !== null) {
echo 'OpenID provider found: ' . $react->openid . "\n";
}
$wf = new Net_WebFinger();
$react = $wf->finger('[email protected] ');
foreach ($react as $link) {
echo 'Link: ' . $link->rel . ' to ' . $link->href . "\n";
}
$wf = new Net_WebFinger();
$wf->setCache(
new Cache('file', array('cache_dir' => sys_get_temp_dir() . '/myapp'))
);
$react = $wf->finger('[email protected] ');
$openIdProvider = $react->get('http://specs.openid.net/auth/2.0/provider');