for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @link https://github.com/yiimaker/yii2-social-share
* @copyright Copyright (c) 2017 Yii Maker
* @license BSD 3-Clause License
*/
namespace ymaker\social\share\drivers;
use ymaker\social\share\base\DriverAbstract;
* DriverAbstract for Twitter.
* @link https://twitter.com
*
* @author Vladimir Kuprienko <[email protected]>
* @since 1.0
class Twitter extends DriverAbstract
{
* @var bool|string
public $account = false;
* @inheritdoc
protected function processShareData()
$this->url = static::encodeData($this->url);
$this->description = static::encodeData($this->description);
if (is_string($this->account)) {
$this->appendToData('account', $this->account);
}
protected function buildLink()
$link = 'http://twitter.com/share?url={url}&text={description}';
if ($this->account) {
$this->addUrlParam($link, 'via', '{account}');
return $link;
protected function getMetaTags()
return [
['name' => 'twitter:card', 'content' => 'summary_large_image'],
['name' => 'twitter:title', 'content' => '{title}'],
['name' => 'twitter:description', 'content' => '{description}'],
['name' => 'twitter:image', 'content' => '{imageUrl}']
];