mikeevstropov/vk-parser

此包已被废弃且不再维护。未建议替代包。

社交网络 vk.com 的解析器

1.0.2 2017-06-26 09:14 UTC

This package is not auto-updated.

Last update: 2021-06-26 10:30:25 UTC


README

社交网络 vk.com 的解析器

安装

添加依赖 mikeevstropov/vk-parser

$ composer require mikeevstropov/vk-parser

使用

抱歉,此库将不提供示例。

VideoParser 接口

  • __constructor

    VideoParser 构造函数

    参数

    • client (GuzzleHttp\ClientInterface) - 需要客户端实例
    • logger (null|Psr\Log\LoggerInterface) - 日志记录实例或默认为 null

    返回

    • Mikeevstropov\VkParser\VideoParser
  • getSourceList

    获取源列表

    参数

    • ownerId (string) - 视频所有者的 ID 是必需的
    • id (string) - 视频的 ID 是必需的
    • userSession (null|GuzzleHttp\Cookie\CookieJar) - 用户会话或默认为 null

    返回

    • array - 包含 "static", "embed" 和 "stream" 键
    • false - 视频不存在,私有(成人内容也)或被法律封锁
    • null - 视频源不受支持

ExtendedVideoParser 接口

  • __constructor

    ExtendedVideoParser 构造函数

    参数

    • client (GuzzleHttp\ClientInterface) - 需要客户端实例
    • logger (null|Psr\Log\LoggerInterface) - 日志记录实例或默认为 null
    • cache (null|Psr\SimpleCache\CacheInterface) - 缓存实例或默认为 null

    返回

    • Mikeevstropov\VkParser\ExtendedVideoParser
  • getSourceList

    获取源列表

    参数

    • ownerId (string) - 视频所有者的 ID 是必需的
    • id (string) - 视频的 ID 是必需的
    • userSession (null|GuzzleHttp\Cookie\CookieJar) - 用户会话或默认为 null
    • cache (bool) - 使用缓存,默认为 true
    • cacheTtl (null|int) - 秒数或默认为 null

    返回

    • array - 包含 "static", "embed" 和 "stream" 键
    • false - 视频不存在,私有(成人内容也)或被法律封锁
    • null - 视频源不受支持

开发

克隆

$ git clone https://github.com/mikeevstropov/vk-parser.git

进入项目

$ cd vk-parser

安装依赖项

$ composer install

设置权限

$ sudo chmod 777 ./var -v -R

phpunit.xml 中配置测试环境。确保环境变量 "userLogin","userPassword" 和 "applicationId" 不为空。

<phpunit>
    <php>
        <env name="logLevel" value="DEBUG"/>
        <env name="logFile" value="var/logs/parser.test.log"/>
        <env name="memcachedConnection" value="memcached://"/>
        <env name="userLogin" value=""/>
        <env name="userPassword" value=""/>
        <env name="applicationId" value=""/>
    </php>
</phpunit>

增加 composer 超时时间。由于 composer 默认设置为 300 秒。

$ composer config --global process-timeout 900

运行测试

$ composer test