This package is abandoned and no longer maintained. The author suggests using the cvo-technologies/cakephp-twitter package instead.

CakePHP webservice implementation for Twitter

Installs: 17

Dependents: 0

Suggesters: 0

Security: 0

Stars: 19

Watchers: 4

Forks: 3

Type:cakephp-plugin

1.2.0 2016-08-14 22:50 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:51:50 UTC


README

Software License Build Status Coverage Status Total Downloads Latest Stable Version

Installation

Using Composer

composer require cvo-technologies/cakephp-twitter

Ensure require is present in composer.json:

{
    "require": {
        "cvo-technologies/cakephp-twitter": "~1.1"
    }
}

Load the plugin

Plugin::load('Muffin/Webservice', ['bootstrap' => true]);
Plugin::load('CvoTechnologies/Twitter');

Configure the Twitter webservice

Add the following to the Datasources section of your application config.

        'twitter' => [
            'className' => 'Muffin\Webservice\Connection',
            'service' => 'CvoTechnologies/Twitter.Twitter',
            'consumerKey' => '',
            'consumerSecret' => '',
            'oauthToken' => '',
            'oauthSecret' => ''
        ]

Usage

Controller

namespace App\Controller;

use Cake\Event\Event;

class StatusesController extends AppController
{
    public function beforeFilter(Event $event)
    {
        $this->loadModel('CvoTechnologies/Twitter.Statuses', 'Endpoint');
    }

    public function index()
    {
        $statuses = $this->Statuses->find()->where([
            'screen_name' => 'CakePHP',
        ]);

        $this->set('statuses', $statuses);
    }
}

Streaming example

This is an example of how to implement the Twitter streaming API.

namespace App\Shell;

use Cake\Console\Shell;

class StreamShell extends Shell
{
    public function initialize()
    {
        $this->modelFactory('Endpoint', ['Muffin\Webservice\Model\EndpointRegistry', 'get']);
        $this->loadModel('CvoTechnologies/Twitter.Statuses', 'Endpoint');
    }

    public function main()
    {
        $statuses = $this->Statuses
            ->find('filterStream', [
                'word' => 'twitter',
            ]);

        foreach ($statuses as $status) {
            echo $status->text . PHP_EOL;
        }
    }
}