s37dap42x/yandex-rich-content-api

Yandex Rich Content API 的客户端

1.1.2 2015-11-06 08:33 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:03:56 UTC


README

Yandex Rich Content API 的客户端

Rich Content API 提供了对包含数十亿页面的 Yandex 内容系统的访问。对于其中的任何一页,您可以接收摘录、标题和规范形式的 URL,以及完整的文本,还包括包含的图片和视频的链接列表。此 API 对用户交换链接的服务非常有用。它允许用户在离开服务前预览任何网页。

API 参考

版本管理

包版本与 API 版本相对应。

安装

使用 composer

composer require s37dap42x/yandex-rich-content-api

或手动添加到您的 composer.json

{
  "require": {
    "s37dap42x/yandex-rich-content-api": "1.1.*"
  }
}

然后使用更新命令: composer update

使用方法

获取您的 API 密钥

use Yandex\RichContentAPI\RichContent;

$key = "rca.1.1...";
$url = "http://yandex.com";

try {
    $yandex = new RichContent($key);

    // Set optional parameters
    $yandex->setOptions(['img' => 'no', 'content' => 'full']);

    $data = $yandex->getContent($url);
    var_dump($data); // object
} catch (Exception $e) {
    echo $e->getMessage();
}

# 许可证

MIT