mineur/twitter-stream-api-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mineur/twitter-stream-api-bundle

Composer 安装命令:

composer require mineur/twitter-stream-api-bundle

包简介

A bundle integration of Mineur twitter stream api for Symfony

README 文档

README

License Latest Unstable Version Total Downloads

A Symfony integration of Mineur Twitter Stream Library.

Installation

composer require mineur/twitter-stream-api-bundle:dev-master

Basic initialization

Register this bundle into your application kernel.

// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new Mineur\TwitterStreamApiBundle\TwitterStreamApiBundle(),
        ];
    }
}

Then add your authentication keys on your config file:

# app/config/config.yml

twitter_stream_api:
    twitter:
        consumer_key: '%your_consumer_key%'
        consumer_secret: '%your_consumer_secret%'
        access_token: '%your_access_token%'
        access_token_secret: '%your_access_token_secret%'

Simple custom command usage

// Controllers/DemoController.php

class DemoCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        //...
    }
    
    public function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var PublicStream $publicStream */
        $publicStream = $this
            ->getContainer()
            ->get('twitter_stream_api_consumer');
        $publicStream
            ->listenFor([
                'your', 
                'keywords', 
                'list'
            ])
            ->setLanguage('es')
            ->do(function(Tweet $tweet) {
                // you can do whatever you want with this output
                // prompt it, enqueue it, persist it into a database ...
                $output->writeln($tweet);
            });
    }
}

Check out the library for full customization of the public stream: twitter-stream-api

Command line actions

Tu use the pre-configured commands:

  • To prompt the stream feed on your terminal:
bin/console mineur:twitter-stream:consume hello,hola,aloha
  • To enqueue the stream output as a serialized objects in a FIFO Redis queue, type the following:

This part is subject to RSQueue library and RSQueueBundle. I recommend you to check the RSQueue documentation to consume the enqueued objects.

bin/console mineur:twitter-stream:enqueue

The Tweet output

Consuming the stream will give you an infinite loop of hydrated Tweet objects, similar to this one:

Mineur\TwitterStreamApi\Tweet {#424
  -text: "Hello twitter!"
  -lang: "en"
  -createdAt: "Thu May 25 18:48:05 +0000 2017"
  -timestampMs: "1495738085984"
  -geo: array:12 [
    // ...
  ]
  -coordinates: array:14 [
    // ...
  ]
  -places: null
  -retweetCount: 236
  -favoriteCount: 52
  -user: array:38 [
    "id" => 2605080321
    // ...
  ]
}

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固