$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')); ?> "> Share on Facebook (<?php echo $socialShare->getShares(Facebook::NAME, 'https://dunglas.fr'); ?> ) </a> </li> <li> <a href="<?php echo htmlspecialchars($socialShare->getLink(Twitter::NAME, 'https://dunglas.fr', array('via' => '@dunglas', 'text' => 'Kévin Dunglas\' SocialShare library'))); ?> "> Share on Twitter (<?php
/** * @param string $provider * @param string $url * @param array $options * * @return string * @throws \RuntimeException If requested provider is undefined */ public function getShareLinkUrl($provider, $url, array $options = array()) { return $this->socialShare->getLink($provider, $url, $options); }
/** * @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); }