exs/feeds-chaturbate-bundle

此插件读取Chaturbate的API以获取现场表演者的信息。

v0.0.4 2017-10-16 15:54 UTC

This package is auto-updated.

Last update: 2024-08-29 04:41:26 UTC


README

Build Status

安装

此插件使用PHP的原生Memcached对象

确保在您的PHP安装中已启用memcached模块。

使用Composer要求此插件

$ composer require exs/feeds-chaturbate-bundle

在AppKernel中启用插件

<?php
// app/AppKernel.php

class AppKernel extends Kernel
{
    // ...
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new EXS\FeedsChaturbateBundle\EXSFeedsChaturbateBundle(),
        );
    }
}

配置

提供了一些配置来管理缓存。

# Default values
exs_feeds_chaturbate:
    cache_ttl: 300
    memcached_host: 'localhost'
    memcached_port: 11211

用法

/**
 * Returns live performers information.
 */
$performers = $container
    ->get('exs_feeds_chaturbate.feeds_reader')
    ->getLivePerformers()
;

/**
 * Performers information  are like :
 *
 * $performers = [
 *     [
 *         'num_followers' => 999,
 *         'display_name' => "XXX",
 *         'tags' => [
 *             "XXX",
 *         ],
 *         'location' => "XXX",
 *         'username' => "XXX",
 *         'spoken_languages' => "XXX",
 *         'is_hd' => true,
 *         'seconds_online' => 999,
 *         'gender' => "X",
 *         'age' => 99,
 *         'num_users' => 999,
 *         'room_subject' => "XXX",
 *     ],
 *     ...
 * ];
 */

如果需要强制刷新Memcached记录,也可以使用一个命令。

$ app/console feeds:chaturbate:refresh-live-performers --env=prod --no-debug

// Can specify cache lifetime
$ app/console feeds:chaturbate:refresh-live-performers --ttl=3600 --env=prod --no-debug