PHP code example of cybercog / yii2-twittable

1. Go to this page and download the library: Download cybercog/yii2-twittable 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/ */

    

cybercog / yii2-twittable example snippets


$sql = "ALTER TABLE news
        ADD COLUMN tweet_id BIGINT(64) NULL DEFAULT NULL";
$this->execute($sql);

$sql = "ALTER TABLE news
        DROP COLUMN tweet_id";
$this->execute($sql);

use cybercog\yii\twittable\behaviors\TwittableBehavior;

/**
 * ...
 * @property string $tagNames
 */
class Post extends \yii\db\ActiveRecord
{
    public function behaviors()
    {
        return [
            [
                'class' => TwittableBehavior::className(),
                'consumerKey' => 'TWITTER_CONSUMER_KEY',
                'consumerSecret' => 'TWITTER_SECRET_KEY',
                'accessToken' => 'TWITTER_ACCESS_TOKEN',
                'accessTokenSecret' => 'TWITTER_SECRET_TOKEN',
                'autoPosting' => true,
            ],
        ];
    }
}
bash
$ php composer.phar