承接 rooxie/omdb 相关项目开发

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

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

rooxie/omdb

Composer 安装命令:

composer require rooxie/omdb

包简介

A PHP wrapper for OMDb API

README 文档

README

Introduction

A PHP wrapper for OMDb API with PSR-17 HTTP Factories and PSR-18 HTTP Client.

Prerequisites

  • PHP >= 8.1
  • Any PSR-17 and PSR-18 compatible HTTP client

Installation

Install omdb-php using Composer.

# Install the package
composer require rooxie/omdb

# Install the PSR-17 and PSR-18 implementations
composer require guzzlehttp/guzzle

Usage

Create an instace of OMDb class, providing the API key as the constructor argument

$omdb = new Rooxie\OMDb(
    new \GuzzleHttp\Client(),
    new \GuzzleHttp\Psr7\HttpFactory(),
    'your-api-key'
);

Get title by IMDb ID

One gets an instance of Movie model class after fetching movie data vit HTTP request

$movie = $omdb->getByImdbId('tt0110912');
// {"Title":"Pulp Fiction","Year":"1994","Rated":"R","Released":"14 Oct 1994" ...
echo $movie->getBody()->getContents();

Get by title and other optional arguments

Same goes for fetching data using movie title. One can also provide optional arguments such as movie type (movie, series or episode) and the release year

$movie = $omdb->getByTitle('harry potter', \Rooxie\Enum\TitleType::MOVIE, 2004);
// {"Title":"Harry Potter and the Prisoner of Azkaban","Year":"2004","Rated":"PG","Released":"04 Jun 2004" ...
echo $movie->getBody()->getContents();

Search by title and other optional arguments

Movie search method returns a raw array from the API response and has an optional pagination parameter as the last argument

$movies = $omdb->search('arrival', \Rooxie\Enum\TitleType::MOVIE, 2016, 1)->getBody()->getContents();
print_r(json_decode($movies, true));
Array
(
    [Search] => Array
        (
            [0] => Array
                (
                    [Title] => Arrival
                    [Year] => 2016
                    [imdbID] => tt2543164
                    [Type] => movie
                    [Poster] => https://m.media-amazon.com/images/M/MV5BMTExMzU0ODcxNDheQTJeQWpwZ15BbWU4MDE1OTI4MzAy._V1_SX300.jpg
                )

            [1] => Array
                (
                    [Title] => Alien Arrival
                    [Year] => 2016
                    [imdbID] => tt3013160
                    [Type] => movie
                    [Poster] => https://m.media-amazon.com/images/M/MV5BMjE5ODg2MTUtMDQ3Ny00MjA2LWJmZjMtYThlNTY3NGJhZmI2XkEyXkFqcGdeQXVyMjA4MDYxNDk@._V1_SX300.jpg
                )

            [2] => Array
                (
                    [Title] => The Arrival
                    [Year] => 2016
                    [imdbID] => tt5623378
                    [Type] => movie
                    [Poster] => https://images-na.ssl-images-amazon.com/images/M/MV5BNTMyMDRhODgtOTE4Yi00MGI5LTllMDUtNThhYWM0ZGVhZTg1XkEyXkFqcGdeQXVyNjQ2NzI0Mw@@._V1_SX300.jpg
                )

            [3] => Array
                (
                    [Title] => Arrival
                    [Year] => 2016
                    [imdbID] => tt5433758
                    [Type] => movie
                    [Poster] => https://images-na.ssl-images-amazon.com/images/M/MV5BMTNiMDRlMDQtZTVkNS00MWVhLWFiOGUtMTkxNTgzODBkMWIyXkEyXkFqcGdeQXVyMjMxMTU4MzA@._V1_SX300.jpg
                )

            [4] => Array
                (
                    [Title] => The Arrival of the Train at a Subway Station in Vienna
                    [Year] => 2016
                    [imdbID] => tt5972896
                    [Type] => movie
                    [Poster] => https://images-na.ssl-images-amazon.com/images/M/MV5BMGVlY2MwYWUtODE1Zi00NGNjLWJjMDgtM2M0ZmJmYTFmMWM4XkEyXkFqcGdeQXVyNDcwNDE0Nzk@._V1_SX300.jpg
                )

            [5] => Array
                (
                    [Title] => Arrival: Common Ground
                    [Year] => 2016
                    [imdbID] => tt6196852
                    [Type] => movie
                    [Poster] => https://images-na.ssl-images-amazon.com/images/M/MV5BMTE4ZjA0MjctNmY0Yy00OWE2LTk1ZTItZmViZDg3ODQwY2NjL2ltYWdlL2ltYWdlXkEyXkFqcGdeQXVyMzM2MjIzNA@@._V1_SX300.jpg
                )

            [6] => Array
                (
                    [Title] => The Arrival
                    [Year] => 2016
                    [imdbID] => tt5678770
                    [Type] => movie
                    [Poster] => N/A
                )

            [7] => Array
                (
                    [Title] => Dead on Arrival
                    [Year] => 2016
                    [imdbID] => tt5175144
                    [Type] => movie
                    [Poster] => N/A
                )

            [8] => Array
                (
                    [Title] => Arrival of a Train At
                    [Year] => 2016
                    [imdbID] => tt5333154
                    [Type] => movie
                    [Poster] => http://ia.media-imdb.com/images/M/MV5BY2M2YWYyMDUtNGM5MC00Y2YwLTkzZWEtNzgzOGEzYTQxYmQwXkEyXkFqcGdeQXVyNjQ3Mjc0Nzg@._V1_SX300.jpg
                )

            [9] => Array
                (
                    [Title] => Arrival of Their Majesties the Emperor and Empress of Japan
                    [Year] => 2016
                    [imdbID] => tt5378228
                    [Type] => movie
                    [Poster] => N/A
                )

        )

    [totalResults] => 10
    [Response] => True
)

Error Handling

Error handling fully depends on the PSR-18 HTTP client implementation. One can catch exceptions thrown by the HTTP client and handle them accordingly.

rooxie/omdb 适用场景与选型建议

rooxie/omdb 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 223 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「imdb」 「movies」 「ratings」 「films」 「omdb」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 rooxie/omdb 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rooxie/omdb 我们能提供哪些服务?
定制开发 / 二次开发

基于 rooxie/omdb 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-04