定制 starcitizenwiki/mediawikiapi 二次开发

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

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

starcitizenwiki/mediawikiapi

Composer 安装命令:

composer require starcitizenwiki/mediawikiapi

包简介

Laravel Package to interact with a Mediawiki Installation through the API, authenticated via OAuth

README 文档

README

packagist version packagist downloads />
    <img src=

Laravel Package to interact with a Mediawiki Installation through the API, authenticated via OAuth.

composer require starcitizenwiki/mediawikiapi

Installation

Publish the configuration php artisan vendor:publish.
Select StarCitizenWiki\MediaWikiApi\ApiServiceProvider

A registered OAuth application is required on the target wiki if pages should be editable through the api.

Facade

Accessible through MediaWikiApi.

Login

$manager = app('mediawikiapi.manager');

$manager->setConsumerFromCredentials(
    'ConsumerToken',
    'ConsumerSecret'
);

$manager->setTokenFromCredentials(
    'AccessToken',
    'AccessSecret'
);

BaseRequest

Each request object extend the BaseRequest class.
The base request class contains the following methods:

$request->queryParams(); // Returns the query params as an array
$request->json(); // Set the request format to 'json'
$request->csrfToken('TOKEN'); // Set the csrf token for this request
$request->formatVersion('latest'); // Set the formatversion. Valid values are 1, 2, 'latest'
$request->withTimestamp(); // Set the 'curtimestamp' param to 1
$request->addParam('key', 'value');
$request->request(); // Send the request, returns a MediaWikiResponse
$request->request([ 
  'timeout' => 10,
]); // Send the request with additional GuzzleClient options

Query

Methods

$query = MediaWikiApi::query();

// Add meta params
$query->meta('tokens'); // Param meta is now 'tokens'
$query->meta('siteinfo')->meta('...'); // Param meta is now 'tokens|siteinfo|...'

// Add prop params
$query->prop('categories'); // Param prop is now 'categories'

// Set the pages to work on
$query->titles('Title1|Title2');
// Or
$query->titles('Title1')->titles('Title2');

// Set a category limit if prop('categories') was set
$query->cllimit(-1); // return 'max'
$query->cllimit(100); // return 100

// Force authentication
$query->withAuthentication();

Request a CSRF token:

$response = MediaWikiApi::query()->meta('tokens')->request();

// True if request was not successful
$response->hasErrors(); // boolean
$response->getErrors(); // array

// True if request has warnings
$response->hasWarnings(); // boolean
$response->getWarnings(); // array

$token = $response->getQuery()['tokens'];

Parse

Methods

$parse = MediaWikiApi::parse();

// Set a page to parse
$parse->page('Example');

// Add prop params
$parse->prop('text'); // Param prop is now 'text'

Edit

Methods

$edit = MediaWikiApi::edit();

// Set the page title to edit
// Unsets a previously set page ID!
$edit->title('Example');

// Or use a page ID
// Unsets a previously set title!
$edit->pageId(1);

// Add text to the page
// Automatically sets the md5 hash
$edit->text('Content');

// Edit an existing section
$edit->section(1);

// Add a new section
$edit->section();

// Set the section title
$edit->sectionTitle('Title');

// Set an edit summary
$edit->summary('This was an API edit');

// Set mode to create only
$edit->createOnly();

// Set edit to minor
// Unsets not minor
$edit->minor();

// Set edit to notminor
// Unsets minor
$edit->notMinor();

// Set edit as bot edit
$edit->markBotEdit();

// Set the CSRF Token
$edit->csrfToken('token');

Action

A generic class for requesting arbitrary API actions

// Creates an action object with ?action=action-name, request method to 'GET' and auth to false
$action = MediaWikiApi::action('action-name');

// Creates an action object with ?action=foo, request method to 'POST' and auth to true
$actionPostAuth = MediaWikiApi::action('foo', 'POST', true);

// Creates an action object with ?action=bar
$actionBar = MediaWikiApi::action('bar');
$actionBar->withAuthentication(); // auth is now true

// Adding parameters
$action->addParam('name', 'value'); // &name=value

$action->addParam('delete', true); // &delete=true

starcitizenwiki/mediawikiapi 适用场景与选型建议

starcitizenwiki/mediawikiapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.44k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2020 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-08-04