scriptotek/oai-pmh-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scriptotek/oai-pmh-client

最新稳定版本:v0.7.1

Composer 安装命令:

composer require scriptotek/oai-pmh-client

包简介

Package for harvesting data from OAI-PMH repositories

关键字:

README 文档

README

Build Status Coverage Code Quality Latest Stable Version Total Downloads

Note: This package is abandoned. I recommend using the caseyamcl/phpoaipmh package instead. It has an almost identical interface, great code quality and more contributors, so I see no reason to continue maintaining this package.

php-oai-pmh-client

Simple PHP client package for fetching data from an OAI-PMH server, using the Guzzle HTTP client. The returned data is parsed by QuiteSimpleXMLElement.

On network problems, the client will retry a configurable number of times, emitting a request.error event each time, before finally throwing a ConnectionError.

Install using Composer

composer require scriptotek/oai-pmh-client

Example

require_once('vendor/autoload.php');
use Scriptotek\OaiPmh\Client as OaiPmhClient;

$url = 'http://oai.bibsys.no/repository';

$client = new OaiPmhClient($url, array(
    'schema' => 'marcxchange',
    'user-agent' => 'MyTool/0.1',
    'max-retries' => 10,
    'sleep-time-on-error' => 30,
));

Fetching a single record

try {
    $record = $client->record('oai:bibsys.no:biblio:113889372');
} catch (Scriptotek\OaiPmh\ConnectionError $e) {
    echo $e->getMsg();
    die;
} catch (Scriptotek\OaiPmh\BadRequestError $e) {
    echo 'Bad request: ' . $e->getMsg() . "\n";
    die;
}

echo $record->identifier . "\n";
echo $record->datestamp . "\n";
echo $record->data->asXML() . "\n";

Iterating over a record set

foreach ($client->records('') as $record) {
	echo $record->identifier . "\n";
	echo $record->datestamp . "\n";
}

Events

$client->on('request.start', function($verb) {
    print "Starting " . $verb . " request\n";
});
$client->on('request.error', function($err) {
    print "Non-fatal error: " . $err . "\n";
});
$client->on('request.complete', function($verb) {
    print "Completed " . $verb . " request\n";
});

API documentation

API documentation can be generated using e.g. Sami, which is included in the dev requirements of composer.json.

php vendor/bin/sami.php update sami.config.php -v

You can view it at scriptotek.github.io/php-oai-pmh-client

统计信息

  • 总下载量: 507
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-15