kaspars/hunter
Composer 安装命令:
composer require kaspars/hunter
包简介
Hunter is an easy to use uHunt wrapper to receive information from UVA servers.
README 文档
README
Introduction
Hunter is an easy to use uHunt wrapper to receive information from UVa's online judge.
Hunter is licensed under the MIT License - see the LICENSE file for details.
Basic Usage
use Hunter\Hunter; require "vendor/autoload.php"; $hunter = new Hunter(); echo $hunter->getIdFromUsername("Kaspars");
Installing
With Composer
The easiest and recommended method to install Hunter is via composer.
Use the following command to install with composer.
$ composer require kaspars/hunter
If you wish you can create the following composer.json file and run composer install to install it.
{
"require": {
"kaspars/hunter": "~1.0"
}
}
Direct Download
First of all, you really should use composer.. But if you insist, then just copy the content from src folder into your project
Data Format
All data is returned as an associated array.
Problem format
idProblem IDnumberProblem numbertitleProblem titledacuNumber of distinct accepted usersbestRuntimeBest runtime in milliseconds of an Accepted SubmissionverdictsAn array given verdictsHunter\Status::NO_VERDICTNumber of No Verdict Given (can be ignored)Hunter\Status::SUBMISSION_ERRORNumber of Submission ErrorHunter\Status::CANT_BE_JUDGEDNumber of Can't be JudgedHunter\Status::IN_QUEUENumber of In QueueHunter\Status::COMPILATION_ERRORNumber of Compilation ErrorHunter\Status::RESTRICTED_FUNCTIONNumber of Restricted FunctionHunter\Status::RUNTIME_ERRORNumber of Runtime ErrorHunter\Status::OUTPUT_LIMITNumber of Output Limit ExceededHunter\Status::TIME_LIMITNumber of Time Limit ExceededHunter\Status::MEMORY_LIMITNumber of Memory Limit ExceededHunter\Status::WRONG_ANSWERNumber of Wrong AnswerHunter\Status::PRESENTATION_ERRORNumber of Presentation ErrorHunter\Status::ACCEPTEDNumber of Accepted
limitProblem runtime limit in millisecondsstatusProblem StatusHunter\Status::UNAVAILABLEUnavailableHunter\Status::NormalNormalHunter\Status::SPECIAL_JUDGEA special judging program is used.
rejudgedLast time (unix timestamp) the problem was rejudged,nullif never.
Submission format
idSubmission`s IDuserUser IDnameUser's full nameusernameUser`s usernameproblemProblem's IDverdictGiven verdictHunter\Status::SUBMISSION_ERRORSubmission ErrorHunter\Status::CANT_BE_JUDGEDCan't be JudgedHunter\Status::IN_QUEUEIn QueueHunter\Status::COMPILATION_ERRORCompilation ErrorHunter\Status::RESTRICTED_FUNCTIONRestricted FunctionHunter\Status::RUNTIME_ERRORRuntime ErrorHunter\Status::OUTPUT_LIMITOutput Limit ExceededHunter\Status::TIME_LIMITTime Limit ExceededHunter\Status::MEMORY_LIMITMemory Limit ExceededHunter\Status::WRONG_ANSWERWrong AnswerHunter\Status::PRESENTATION_ERRORPresentation ErrorHunter\Status::ACCEPTEDAccepted
languageLanguage in which submission was writtenHunter\Language::ANSI_CAnsi CHunter\Language::JavaJavaHunter\Language::CPLUSPLUSC++Hunter\Language::PASCALPascalHunter\Language::CPLUSPLUS11C++11Hunter\Language::PYTHONPython
runtimeRuntime in millisecondsrankSubmission rank, compared to alltimeSubmission unix timestamp
Ranklist format
idUser`s IDnameUser`s nameusernameUser`s usernamerankUser's rankacceptedThe number of accepted problemssubmissionsThe number of submissionsactivityArray of user's activityHunter\Activity::DAYSActivity in the last 2 daysHunter\Activity::WEEKActivity in the last 7 daysHunter\Activity::MONTHActivity in the last 31 daysHunter\Activity::QUARTERActivity in the last 3 monthsHunter\Activity::YEARActivity in the last year
#API
##getIdFromUsername(string $username)
Convert the given $username to a UVa ID.
Returns either the id, or null if not found
$hunter = new Hunter\Hunter(); echo $hunter->getIdFromUsername("Kaspars"); //343417 echo $hunter->getIdFromUsername("Foobar"); // null
Examples
problems(void)
Returns an array of available UVa problems
$hunter = new Hunter\Hunter(); var_dump($hunter->problems());
problem(int $id, string $type = "id")
Retrieved data of a specific problem
$hunter = new Hunter\Hunter(); var_dump($hunter->problem(36)); var_dump($hunter->problem(100, "num"));
problemSubmissions(array|int $problemIDS, int $start = 0, int $end = 2^31)
View submissions to specific problems on a given submission date range.
$start and $end are unix timestamps
$hunter = new Hunter\Hunter(); var_dump($hunter->problemSubmissions(36)); var_dump($hunter->problemSubmissions(array(36,37)));
problemRanklist(int $problemID, int $rank = 1, int $count = 100)
Returns submissions to a problem ranked from $rank to $rank + $count - 1.
$hunter = new Hunter\Hunter(); var_dump($hunter->problemRanklist(36));
userProblemRanklist(int $problemID, int $userID, int $above = 10, int $below = 10)
Returns nearby submissions (by runtime) for a particular user submission to a problem.
$hunter = new Hunter\Hunter(); var_dump($hunter->userProblemRanklist(36, 343417));
userSubmissions(int $userID, int $min = null)
Returns all of the submissions of a particular user.
if $min is specified, only submissions with ID larger than $min will be returned.
$hunter = new Hunter\Hunter(); var_dump($hunter->userSubmissions(343417));
userLatestSubmissions(int $userID, int $count = 10)
Returns the last $count submissions of a particular user.
$hunter = new Hunter\Hunter(); var_dump($hunter->userLatestSubmissions(343417));
userProblemSubmissions(array|int $userIDs, array|int $problemIDs, int $min, string $type = "id")
Returns all the submissions of the users on specific problems.
Possible $type values are id and num. This changes whether you pass problem id's or problem num's as the second argument.
$hunter = new Hunter\Hunter(); var_dump($hunter->userProblemSubmissions(343417, 36);
userSolvedProblems(array|int $userIDs)
Get The Bit-Encoded-Problem IDs that Has Been Solved by Some Authors.
$hunter = new Hunter\Hunter(); var_dump($hunter->userSolvedProblems(343417));
userRanklist(int $userID, int $above = 10, int $below = 10)
Returns the user's ranklist and their closest neighbors.
$hunter = new Hunter\Hunter(); var_dump($hunter->userRanklist(343417, 10, 10));
ranklist(int $rank = 1, int $count = 10)
Global ranklist, starteing from $rank to $rank+$count
$hunter = new Hunter\Hunter(); var_dump($hunter->ranklist(1, 100));
setSource(string $source)
Change the source of API data. The default is http://uhunt.felix-halim.net/api/, another valid source is http://icpcarchive.ecs.baylor.edu/uhunt/api/. But you can switch to any source that has the same data format.
$hunter = new Hunter\Hunter(); var_dump($hunter->setSource('http://icpcarchive.ecs.baylor.edu/uhunt/api/'));
getSource()
Returns the current used API source.
$hunter = new Hunter\Hunter(); var_dump($hunter->getSource());
kaspars/hunter 适用场景与选型建议
kaspars/hunter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 71 次下载、GitHub Stars 达 8, 最近一次更新时间为 2015 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「online judge」 「uva」 「uhunt」 「competitive programming」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kaspars/hunter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kaspars/hunter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kaspars/hunter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Client for Sphere Engine
PHP and Laravel HackerRank Code Checker API
Judge handles feature and value toggles/flaggings for Laravel.
Laravel PayMob online payment gateway package
Simple Telegra.ph API PHP Client
Iranian payment gateways handler for laravel applicationss
统计信息
- 总下载量: 71
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-19