likey/wiqi

此包的最新版本(dev-master)没有可用的许可证信息。

Wiqi - 维基百科API查询接口:Laravel 5包,用于轻松执行对维基百科API的 'action=query' 请求。

dev-master 2016-03-24 21:57 UTC

This package is not auto-updated.

Last update: 2024-09-14 00:52:32 UTC


README

关于

此项目是Laravel 5的维基百科API查询接口。一个用于执行对维基百科API的 "action=query" 请求的简单接口。

安装

添加到你的 composer.json

{
    "require": {
        "likey/wiqi": "dev-master"
    }
}

或从命令行

composer require likey/wiqi

在 /config/app.php 中添加服务提供者

    Likey\Wiqi\WiqiServiceProvider::class,

示例

'providers' => [
    Likey\Wiqi\WiqiServiceProvider::class,
],

添加外观

    'Wiqi'      => Likey\Wiqi\Facades\Wiqi::class,

示例

'aliases' => [
    'Wiqi'      => Likey\Wiqi\Facades\Wiqi::class,
]

使用方法

可能在开发中有所变化。

get() - 返回查询结果的数组

$wiqiResults = Wiqi::query("like")->get();
print_r($wiqiResults);

count(int) - 结果中的更多页面

$wiqiResults = Wiqi::query("like")->count(5)->get();
print_r($wiqiResults);

brief() - 将第一句话和图片添加到结果中

$wiqiResults = Wiqi::query("like")->brief()->count(5)->get();
print_r($wiqiResults);

示例返回

[
{
"pageid": 567140,
"title": "Like",
"extract": "In the English language, the word like has a very flexible range of uses, ranging from conventional to non-standard."
},
{
"pageid": 1215338,
"title": "Like a Rolling Stone",
"extract": "\"Like a Rolling Stone\" is a 1965 song by the American singer-songwriter Bob Dylan.",
"image": "https://upload.wikimedia.org/wikipedia/en/1/1e/Bob_Dylan_-_Like_a_Rolling_Stone.jpg"
},
{
"pageid": 167924,
"title": "Like Mike",
"extract": "Like Mike is a 2002 American comedy film directed by John Schultz and written by Michael Elliot and Jordan Moffet.",
"image": "https://upload.wikimedia.org/wikipedia/en/e/ee/Like_Mike_poster.jpg"
},
{
"pageid": 28504903,
"title": "Like a G6",
"extract": "\"Like a G6\" is a 2010 song written and performed by Far East Movement, The Cataracs, and Dev, with the latter two being credited as featured artists.",
"image": "https://upload.wikimedia.org/wikipedia/en/5/59/Like_a_G6_single_cover.jpg"
},
{
"pageid": 9737001,
"title": "Like Sonny",
"extract": "Like Sonny is a compilation album combining two sessions from 1958 and 1960 with jazz musician John Coltrane.",
"image": "https://upload.wikimedia.org/wikipedia/en/f/fd/Like_Sonny.jpeg"
}
]

许可证

版权所有 2015 Likey, LLC.