ppp/wikidataquery-api

用于与 WikidataQuery API 交互的库

1.4 2016-04-07 15:04 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:11:06 UTC


README

Build Status Code Coverage Scrutinizer Code Quality Dependency Status

Packagist上: 最新稳定版本 下载次数

WikidataQueryApi 是WikidataQuery 工具的一个小型包装器。它仅支持查询语法的一个子集。

安装

使用以下方法之一

1 - 使用 composer 通过 master 分支安装库及其所有依赖项

composer require "ppp/wikidataquery-api":dev-master"

2 - 创建一个 composer.json 文件,只定义对该包版本 1.0 的依赖,然后在目录中运行 'composer install'

{
    "require": {
        "ppp/wikidataquery-api": "~1.0"
    }
}

示例

以下是一个简单的使用示例

// Load everything
require_once( __DIR__ . '/vendor/autoload.php' );

// Initialise HTTP connection
$api = new WikidataQueryApi( 'https://wdq.wmflabs.org/api' );

// Build helper tools
$wikidataQueryFactory = new WikidataQueryFactory( $api );
$simpleQueryService = $wikidataQueryFactory->newSimpleQueryService();

//Do a query that returns a list of ItemId
//This query finds all the children (P40) of Charlemagne (Q3044)
$itemIds = $simpleQueryService->doQuery(
	new ClaimQuery( new PropertyId( 'P17' ), new ItemId( 'Q3044' ) );
);