在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:addwiki/mediawiki-api开源软件地址:https://github.com/addwiki/mediawiki-api开源编程语言:PHP 98.2%开源软件介绍:mediawiki-apiInstallationUse composer to install the library and all its dependencies:
Example Usage// Load all the stuff
require_once( __DIR__ . '/vendor/autoload.php' );
// Create an authenticated API and services
$auth = new \Addwiki\Mediawiki\Api\Client\Auth\UserAndPassword( 'username', 'password' )
$api = new \Addwiki\Mediawiki\Api\Client\Action\ActionApi( 'http://localhost/w/api.php', $auth );
$services = new \Addwiki\Mediawiki\Api\MediawikiFactory( $api );
// Get a page
$page = $services->newPageGetter()->getFromTitle( 'Foo' );
// Edit a page
$content = new \Addwiki\Mediawiki\DataModel\Content( 'New Text' );
$revision = new \Addwiki\Mediawiki\DataModel\Revision( $content, $page->getPageIdentifier() );
$services->newRevisionSaver()->save( $revision );
// Move a page
$services->newPageMover()->move(
$services->newPageGetter()->getFromTitle( 'FooBar' ),
new Title( 'FooBar' )
);
// Delete a page
$services->newPageDeleter()->delete(
$services->newPageGetter()->getFromTitle( 'DeleteMe!' ),
array( 'reason' => 'Reason for Deletion' )
);
// Create a new page
$newContent = new \Addwiki\Mediawiki\DataModel\Content( 'Hello World' );
$title = new \Addwiki\Mediawiki\DataModel\Title( 'New Page' );
$identifier = new \Addwiki\Mediawiki\DataModel\PageIdentifier( $title );
$revision = new \Addwiki\Mediawiki\DataModel\Revision( $newContent, $identifier );
$services->newRevisionSaver()->save( $revision );
// List all pages in a category
$pages = $services->newPageListGetter()->getPageListFromCategoryName( 'Category:Cat name' ); Running the integration testsTo run the integration tests, you need to have a running MediaWiki instance. The tests will create pages and categories without using a user account so it's best if you use a test instance. Furthermore you need to turn off rate limiting by adding the line $wgGroupPermissions['*']['noratelimit'] = true; to the By default, the tests will use the URL
Warning: Running the integration tests can take a long time to complete. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论