artarts36/head-hunter-api

HeadHunter API 客户端

0.3.7 2020-09-09 11:05 UTC

This package is auto-updated.

Last update: 2024-09-09 20:46:41 UTC


README

PHP Composer License: MIT Total Downloads

描述

用于与https://hh.ru API 交互的客户端

HeadHunter API 文档:https://github.com/hhru/api

安装

composer require artarts36/head-hunter-api

示例

简单示例

use ArtARTs36\HeadHunterApi\Client;
use ArtARTs36\HeadHunterApi\Features\Vacancy\Vacancy;

$client = new Client('https://api.hh.ru', 'MyApp/my@mail.ru');
$feature = new Vacancy($client);
$vacancy = $feature->find(123456789);

var_dump($vacancy->getSpecializations());

在 Laravel 中连接

1*. 在 .env 文件中设置变量

HEADHUNTER_API_BASE_URL='https://api.hh.ru'
HEADHUNTER_API_USER_AGENT='MyApp/my@mail.ru'

2*. 在 bootstrap/app.php 中绑定

$app->singleton(
    \ArtARTs36\HeadHunterApi\Contracts\Client::class,
    function () {
        return new \ArtARTs36\HeadHunterApi\Client(
              env('HEADHUNTER_API_BASE_URL'),
              env('HEADHUNTER_API_USER_AGENT')
        );
    }
);