定制 devcoda25/redtubeapi 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

devcoda25/redtubeapi

最新稳定版本:1.1.0

Composer 安装命令:

composer require devcoda25/redtubeapi

包简介

RedTube API developer documentation! Here you can find detailed information needed to get data and integrate RedTube videos on your website or application

README 文档

README

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 devcoda25/redtubeapi

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 \devcoda25\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) {

}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-24