Jump to content

API:How to make a PHP request

From mediawiki.org
Revision as of 01:22, 2 June 2012 by 50.53.15.51 (talk) (template dab)

How to make a request in PHP

For a beginner in wikimedia development, this link is the most important:

API:Calling internally

And all options can be find here

action=edit

And here:

API

And the code to create a page is:

		global $wgUser;
		echo "<p>".$token = $wgUser->editToken();
		$params = new FauxRequest( array(
			'action'=>'edit',
			'title'=>'Talk:Main_Page',
			'section'=>'new',
			'summary'=>'Hello%20World',
			'text'=>'Hello%20everyone!',
			'watch'=>'',
			'basetimestamp'=>'2008-03-20T17:26:39Z',
			'token'=>$token,
		));
		$enableWrite = true; // This is set to false by default, in the ApiMain constructor
		$api = new ApiMain( $params, $enableWrite );
		$api->execute();
		echo "<p>";
		print_r($data = & $api->getResultData());