承接 realshadow/redtube-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

realshadow/redtube-api

Composer 安装命令:

composer require realshadow/redtube-api

包简介

PHP based API wrapper for Redtube HTTP API

README 文档

README

Scrutinizer Code Quality Build Status

Redtube API

PHP based API wrapper for Redtube HTTP API .

All methods except getStarDetailedList are supported. This method at the time of writing always ends with an There are no stars! error.

Installation

composer require realshadow/redtube-api

Usage

Every method returns either a concrete object representing the response or collection of objects. Methods used for filtering videos return a Paginator object which contains all videos and basic informating about paging (current page, total count, last page, etc.).

// Create new API client (default host points to https://api.redtube.com)
$redtube = new \Realshadow\Redtube\Redtube;

/**
 * Get all categories
 *
 * @return Collection<Category>
 */
$redtube->categories->getAll();

/**
 * Get all stars
 *
 * @return Collection<Star>
 */
$redtube->stars->getAll();

/**
 * Get all tags
 *
 * @return Collection<Tag>
 */
$redtube->tags->getAll();

/**
 * Find videos
 *
 * @return Paginator
 */
$redtube->videos->findBy($filter);

/**
 * Find video by its ID
 *
 * @return Video
 */
$redtube->videos->findById($id);

/**
 * Find out if a video is active
 *
 * @return bool
 */
$redtube->videos->isActive($id);

/**
 * Get embed code of a video
 *
 * @return string
 */
$redtube->videos->getEmbedCode($id);

/**
 * Find deleted videos
 *
 * @return Paginator
 */
$redtube->videos->findDeletedBy($filter);

Video filter

Videos can be filtered by using the VideoFilter class which provides fluent interface. You can use one of three enumerators to ease filtering - Period, OrderBy, Thumbsize.

Note: Redtube does not use traditional limit/offset queries but filtering by page. Each page contains 20 results.

For example

$filter = VideoFilter::create()
    ->page(1)
    ->search('lesbian')
    ->tags(['blonde'])
    ->stars(['Jenna Jameson'])
    ->thumbsize(Thumbsize::BIG)
    ->period(Period::ALL_TIME)
    ->orderBy(OrderBy::RATING);

$videos = $redtube->videos->findBy($filter);

Get all active / deleted videos

If you want to retrieve more than one page (more than 20 videos) at once you can use these methods

/**
 * Find all videos up to 10th page
 *
 * @return Generator
 */
$redtube->videos->findAllBy($filter, 10);

/**
 * Find deleted videos up to the 10th page
 *
 * @return Generator
 */
$redtube->videos->findAllDeletedBy($filter, 10);

Both methods return a generator after each page is requested to ease memory allocation. So the full usage example would be

foreach ($redtube->videos->findAllBy($filter, 10) as $videos) {
    /** @var Illuminate\Support\Collection $videos */

    $videos->each(function (Video $video) {
        // rest of the code
    });
}

Exceptions

All of the error codes listed in documentation are transformed into PHP exceptions by using this mapping

  • error code 1001 => NoSuchMethodException
  • error code 1002 => NoSuchDataProviderException
  • error code 1003 => NoInputParametersSpecifiedException
  • rest of the error codes will use NotFoundException with appropiate message

For example

try {
    $videos = $redtube->videos->findBy($filter);
} catch (NotFoundException $e) {

}

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固