承接 ihoru/wikirandom 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ihoru/wikirandom

Composer 安装命令:

composer require ihoru/wikirandom

包简介

WikiRandom is simple and easy to use php lib that help you to get a random Wikipedia/Wikiquote article and access to some relative raw data.

README 文档

README

###What is WikiRandom? WikiRandom is simple and easy to use php lib that help you to get a random Wikipedia article and access to some relative raw data. Actually the lib is very very simple, you can get basic informations.

###How WikiRandom catch Wikipedia Articles? WikiRandom use Wikimedia API, you can read more at this link: Wikimedia API

###Wow, what is useful for? I use this library for randpedia, a twitter account that every day tweet (automatically) a random article.

###Usage example:

$wr = new WikiRandom("it");
Instance a new WikiRandom Object, this automatically get a random article

$wr->getApiLanguage();
it

$wr->getId();
812464

$wr->getTitle();
5321 Jagras

$wr->getLink();
http://it.wikipedia.org/wiki/5321_Jagras

$wr->getFirstSentence();
5321 Jagras è un asteroide della fascia principale.

$wr->getNChar(25);
5321 Jagras è un asteroide...

$wr->getCategoriesRelated();
array(3) { 
      [0]=> string(42) "Asteroidi della fascia principale centrale" 
      [1]=> string(31) "Corpi celesti scoperti nel 1985" 
      [2]=> string(16) "Stub - asteroidi" 
}

$wr->getOtherLangLinks();

array(10) 
      { [0]=> array(3) 
        { ["lang"]=> string(2) "en" 
          ["url"]=> string(40) "http://en.wikipedia.org/wiki/5321_Jagras" 
          ["*"]=> string(11) "5321 Jagras" } 
        [1]=> array(3) { 
          ["lang"]=> string(2) "eo" 
          ["url"]=> string(41) "http://eo.wikipedia.org/wiki/5321_Jagraso" 
          ["*"]=> string(12) "5321 Jagraso" } 
        [2]=> array(3) { 
          ["lang"]=> string(2) "fa" 
          ["url"]=> string(84) "http://fa.wikipedia.org/wiki/%D8%B3%DB%8C%D8%A7%D8%B1%DA%A9_%DB%B5%DB%B3%DB%B2%DB%B1"               ["*"]=> string(19) "سیا" }
        [3]=> array(3) { 
          ["lang"]=> string(2) "hu" 
          ["url"]=> string(40) "http://hu.wikipedia.org/wiki/5321_Jagras" 
          ["*"]=> string(11) "5321 Jagras" } 
        [4]=> array(3) { 
          ["lang"]=> string(2) "hy" 
          ["url"]=> string(72) "http://hy.wikipedia.org/wiki/(5321)_%D5%8B%D5%A1%D5%A3%D6%80%D5%A1%D5%BD" 
          ["*"]=> string(19) "(5321) Ջագրաս" } 
        [5]=> array(3) { 
          ["lang"]=> string(2) "la" 
          ["url"]=> string(40) "http://la.wikipedia.org/wiki/5321_Jagras" 
          ["*"]=> string(11) "5321 Jagras" } 
        [6]=> array(3) { 
          ["lang"]=> string(2) "oc" 
          ["url"]=> string(40) "http://oc.wikipedia.org/wiki/5321_Jagras" 
          ["*"]=> string(11) "5321 Jagras" } 
        [7]=> array(3) { 
          ["lang"]=> string(2) "pl" 
          ["url"]=> string(42) "http://pl.wikipedia.org/wiki/(5321)_Jagras" 
          ["*"]=> string(13) "(5321) Jagras" } 
        [8]=> array(3) { 
          ["lang"]=> string(2) "pt" 
          ["url"]=> string(40) "http://pt.wikipedia.org/wiki/5321_Jagras" 
          ["*"]=> string(11) "5321 Jagras" } 
        [9]=> array(3) { 
          ["lang"]=> string(2) "uk" 
          ["url"]=> string(64) "http://uk.wikipedia.org/wiki/5321_%D0%AF%D2%91%D1%80%D0%B0%D1%81" 
          ["*"]=> string(15) "5321 Яґрас" 
        } 
}

$wr->getPlainTextArticle();
5321 Jagras è un asteroide della fascia principale. Scoperto nel 1985, presenta un'orbita caratterizzata da un semiasse maggiore pari a 2,5810209 UA e da un'eccentricità di 0,2213576, inclinata di 13,58746° rispetto all'eclittica. Collegamenti esterni (EN) Jagras - Dati riportati nel database dell'IAU Minor Planet Center (EN) Jagras - Dati riportati nel Jet Propulsion Laboratory - Small-Body Database

$wr->getArticleImages();
array(2) { 
      [0]=> string(63) "http://upload.wikimedia.org/wikipedia/commons/8/83/Celestia.png" 
      [1]=> string(76) "http://upload.wikimedia.org/wikipedia/commons/9/9a/Galileo_Gaspra_Mosaic.jpg" 
}
```
###Bulk usage example:
Previous example is bad in situations, when you need to get more than one random article. And if you are going to get all properties it is becoming worse because of many requests to API (every call make one request).

If you need to get just a couple properties, but load more than one article, you can use this syntax:
````php
$wr = new WikiRandom("ru", 5);
$article_ids = $wr->getIds();
$titles = $wr->getTitle();

or the same:

$wr = new WikiRandom("ru", false);
$article_ids = $wr->getNewRandomArticle(5);
$titles = $wr->getTitle();
```

Or you can use more optimized function, but with limited properties:
````php
$wr = new WikiRandom("ru", false);
$data = $wr->getBulkData(5, 5, 0, true);
// requests: 1 + 5 (list and images for every page)

Array
(
    [462957] => Array
        (
            [page_id] => 462957
            [title] => Краснер
            [length] => 229
            [url] => http://ru.wikipedia.org/wiki/%D0%9A%D1%80%D0%B0%D1%81%D0%BD%D0%B5%D1%80
            [text] => <p><b>Краснер</b> — фамилия.</p>
            [images] => Array
                (
                )

        )

    [14836] => Array
        (
            [page_id] => 14836
            [title] => Выбор России (фракция)
            [length] => 27708
            [url] => http://ru.wikipedia.org/wiki/%D0%92%D1%8B%D0%B1%D0%BE%D1%80_%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D0%B8_(%D1%84%D1%80%D0%B0%D0%BA%D1%86%D0%B8%D1%8F)
            [text] =>
            [images] => Array
                (
                )

        )

)


// Makes class to work with wikiquote.org
$wr->setEngine('quote');

```

ihoru/wikirandom 适用场景与选型建议

ihoru/wikirandom 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 ihoru/wikirandom 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GNU-3.0
  • 更新时间: 2014-11-30