Author: Kévin Dunglas (dunglas@gmail.com)
Ejemplo n.º 1
0
<?php

use Doctrine\Common\Cache\PhpFileCache;
use SocialShare\SocialShare;
use SocialShare\Provider\Facebook;
use SocialShare\Provider\Twitter;
use SocialShare\Provider\Google;
use SocialShare\Provider\Pinterest;
use SocialShare\Provider\LinkedIn;
use SocialShare\Provider\ScoopIt;
use SocialShare\Provider\StumbleUpon;
use SocialShare\Provider\Tumblr;
require '../vendor/autoload.php';
$cache = new PhpFileCache(sys_get_temp_dir());
$socialShare = new SocialShare($cache);
$socialShare->registerProvider(new Facebook());
$socialShare->registerProvider(new Twitter());
$socialShare->registerProvider(new Google());
$socialShare->registerProvider(new Pinterest());
$socialShare->registerProvider(new LinkedIn());
$socialShare->registerProvider(new ScoopIt());
$socialShare->registerProvider(new StumbleUpon());
$socialShare->registerProvider(new Tumblr());
?>

<ul>
    <li>
        <a href="<?php 
echo htmlspecialchars($socialShare->getLink(Facebook::NAME, 'https://dunglas.fr'));
?>
">
Ejemplo n.º 2
0
 /**
  * @param string $provider
  * @param string $url
  *
  * @return int
  * @throws \RuntimeException             If requested provider is undefined
  * @throws UnsupportedOperationException If called for an uncompatible provider
  */
 public function getShareCount($provider, $url)
 {
     return $this->socialShare->getShares($provider, $url);
 }
Ejemplo n.º 3
0
 /**
  * @param string $url
  * @param string $title
  * @param string $description
  *
  * @return string <a href="..."> content
  */
 public function getGoogleLink($url, $title = '', $description = '')
 {
     return $this->socialShare->getLink(Google::NAME, $url) . $this->appendHandler(GOOGLE_WIDTH, GOOGLE_HEIGHT);
 }