for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the SocialShare package.
*
* (c) Kévin Dunglas <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SocialShare\Provider;
/**
* Scoop.it!
* @author David Duquenoy <[email protected]>
* @author Kévin Dunglas <[email protected]>
class ScoopIt implements ProviderInterface
{
const NAME = 'scoopit';
const SHARE_URL = 'https://www.scoop.it/bookmarklet?url=%s';
const BUTTON_URL = 'http://www.scoop.it/button?position=horizontal&url=%s';
const DTD = '<!DOCTYPE html>';
* {@inheritdoc}
public function getName()
return self::NAME;
}
public function getLink($url, array $options = array())
return sprintf(self::SHARE_URL, urlencode($url));
public function getShares($url)
$html = file_get_contents(sprintf(self::BUTTON_URL, urlencode($url)));
// Disable libxml errors
$internalErrors = libxml_use_internal_errors(true);
$document = new \DOMDocument();
$document->loadHTML(self::DTD.$html);
$aggregateCount = $document->getElementById('scoopit_count');
// Restore libxml errors
libxml_use_internal_errors($internalErrors);
return intval($aggregateCount->nodeValue);