guilty/recman

1.0.1 2018-10-15 15:27 UTC

This package is auto-updated.

Last update: 2024-09-18 03:09:19 UTC


README

这是一个简单的服务类,用于查询 Recman API,由于Recman对其API有速率限制(每天200次请求),因此提供缓存版本的服务。

安装

通过 Composer

composer require guilty/recman

用法

<?php

// Basic usage
$client = new GuzzleHttp\Client();
$recman = new \Guilty\Recman\RecmanApi(
    "YOUR-API-KEY-HERE",
    $client
);

// Using the provided service with caching, you can use any PSR-16 compatible cache library
$cache = new Symfony\Component\Cache\Simple\FilesystemCache();

// Use DateInterval - See: https://php.ac.cn/manual/en/class.dateinterval.php
$expire = new DateInterval("P1D"); // 1 day

// Or seconds as an integer
$expire = 7200; // 2 hours
$recman = new \Guilty\Recman\CachedRecmanApi(
    "YOUR-API-KEY-HERE",
    $client, $cache, $expire
 );

// Available Methods
$recman->getBranchList();
$recman->getBranchCategoryList();
$recman->getSectorList();
$recman->getExtentList();
$recman->getLocationList($field);
$recman->getJobPostList();
$recman->getDepartmentList();
$recman->getCorporation();
$recman->getCandidateList($page = 1);
$recman->getCandidate($candidateId);
$recman->getCandidateAttributeList();
$recman->getCandidateAttributes();
$recman->getCandidateLanguageList();
$recman->getUserList($departmentIds = [], $corporationIds = [], $tagIds = []);
$recman->getUserTagList();


// If you are using the cache service, but need to get "fresh" data for a
// method call, use the fluent disableCache() method.
$recman->disableCache()->getJobPostList();

// Note that this will disable the cache for all future calls, so use
// enableCache() if you have subsequent calls that require caching
$recman->enableCache()->getDepartmentList();

// Or you can just call it without method chaining, either way the cache
// will be enabled for the rest of the code duration.
$recman->enableCache();

// Cache is enabled again after the previous call
$recman->getBranchList();
$recman->getBranchCategoryList();


// If your API key does not have access to a scope, or if the API key
// is invalid, the API will throw an Exception
try {
    $recman->getCandidateList();
} catch (Exception $exception) {
    var_dump($exception->getMessage()); // string(11) "Invalid key"
    var_dump($exception->getCode());    // int(2)
}

贡献

编写优秀的(现代、可读且符合PSR-2规范的)代码,并在创建问题时保持友好。

安全性

如果您发现任何与安全相关的问题,请通过电子邮件 tech@guilty.no 反馈,而不是使用问题跟踪器。

致谢

许可证

MIT 许可证(MIT)。有关更多信息,请参阅许可证文件