定制 inwebo/item-metadata 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

inwebo/item-metadata

Composer 安装命令:

composer require inwebo/item-metadata

包简介

PHP client library for the Internet Archive Item Metadata API

README 文档

README

A PHP client library for the Internet Archive Item Metadata Write API. It allows you to programmatically update item metadata using JSON Patch (RFC 6902).

Overview

This library provides a clean, object-oriented interface to interact with the Internet Archive (IA) Metadata API. It simplifies the process of creating JSON Patch documents and sending them to the IA servers with proper authentication and formatting.

Key features:

  • Fluent builder for JSON Patch operations (add, remove, replace, move, copy, test).
  • Support for IA S3 authentication (Access Key and Secret Key).
  • Handles double-encoding requirements of the Metadata API.
  • Integration with Symfony HttpClient for robust networking.
  • Specific helper for adding Wayback Machine URLs to user items.

Installation

Install the package via Composer:

composer require inwebo/archive.org-item-metadata-api

API Documentation

ItemMetadataClient

The main entry point for the library.

  • __construct(Credentials $credentials, HttpClientInterface $httpClient): Initializes the client.
  • patch(MetadataWriteRequest $request): MetadataWriteResponse: Sends a JSON Patch request to the API.
  • addWebArchiveUrl(string $userIdentifier, string $archiveUrl, string $target = 'web-archive'): MetadataWriteResponse: Convenience method to append a Wayback Machine URL to a specific target (usually for user-owned items).

Credentials

Used to hold your Internet Archive S3 credentials.

JsonPatch

A fluent builder to create RFC 6902 JSON Patch documents.

  • JsonPatch::create(): Starts a new patch document.
  • add(string $path, mixed $value): Appends an "add" operation. Use /- to append to an array.
  • remove(string $path): Appends a "remove" operation.
  • replace(string $path, mixed $value): Appends a "replace" operation.
  • move(string $from, string $path): Appends a "move" operation.
  • copy(string $from, string $path): Appends a "copy" operation.
  • test(string $path, mixed $value): Appends a "test" operation.

MetadataWriteRequest

Encapsulates the data needed for a write operation.

  • __construct(string $identifier, string $target, JsonPatch $patch, int $priority = 0):
    • identifier: The IA item identifier (e.g., my-item or @my-user).
    • target: The metadata target (e.g., metadata, files/picture.jpg, or a custom user JSON target).
    • patch: The JsonPatch object containing operations.
    • priority: Optional task priority (defaults to 0).

MetadataWriteResponse

The object returned after a successful API call.

  • isSuccess(): bool: Returns true if the operation was successful.
  • getTaskId(): int: Returns the IA task ID created for this update.
  • getLog(): string: Returns the URL to the task log on archive.org.

Usage Examples

Basic Metadata Update

Updating the title and adding a collection to an item:

use Inwebo\ItemMetaData\ItemMetadataClient;
use Inwebo\ItemMetaData\Auth\Credentials;
use Inwebo\ItemMetaData\Patch\JsonPatch;
use Inwebo\ItemMetaData\Request\MetadataWriteRequest;
use Symfony\Component\HttpClient\HttpClient;

$client = new ItemMetadataClient(
    new Credentials('your_access_key', 'your_secret_key'),
    HttpClient::create()
);

$patch = JsonPatch::create()
    ->replace('/title', 'New Improved Title')
    ->add('/collection/-', 'opensource_movies');

$request = new MetadataWriteRequest(
    identifier: 'my-archive-item-id',
    target: 'metadata',
    patch: $patch
);

try {
    $response = $client->patch($request);
    echo "Success! Task ID: " . $response->getTaskId();
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
}

Adding a Wayback Machine URL

A common use case for specific user JSON targets:

$client->addWebArchiveUrl(
    userIdentifier: '@my_username',
    archiveUrl: 'https://web.archive.org/web/20240101000000/https://example.com'
);

License

This project is licensed under the MIT License.

inwebo/item-metadata 适用场景与选型建议

inwebo/item-metadata 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「metadata」 「json-patch」 「archive.org」 「internet-archive」 「wayback-machine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 inwebo/item-metadata 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 inwebo/item-metadata 我们能提供哪些服务?
定制开发 / 二次开发

基于 inwebo/item-metadata 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-22