[Mediawiki-l] Creating wiki pages directly by program

Gilad Ravid gilad at ravid.org
Fri Feb 3 15:23:04 UTC 2006


Hi,

You can use Perl program to submit the HTML forms. I used it to upload few
hundreds of HTML pages to wiki. The main function looks:

my $response=$browser->post("$server/index.php?title=$title&action=submit",
@ns_headers,Content_Type=>'form-data',Content=>[
			wpTextbox1=>$clean_pageU,
			wpSummary=>'',
			wpSave=>"Save page",
			wpSection=>'',
			wpEdittime=>'',
			wpEditToken=>$editToken
		]);

Where the variable $clean_PageU include all the page text.


Gilad



============================================
Facts are stubborn things, but statistics are more pliable. 
--Mark Twain
 
Dr. Gilad Ravid
Tel: +972-8-6472772
Mobile: +972-54-4905391
http://www.ravid.org/gilad
 

-----Original Message-----
From: mediawiki-l-bounces at Wikimedia.org
[mailto:mediawiki-l-bounces at Wikimedia.org] On Behalf Of Hugh Prior
Sent: Thursday, February 02, 2006 4:56 PM
To: mediawiki-l at wikimedia.org
Subject: [Mediawiki-l] Creating wiki pages directly by program

I would like to be able to create wiki pages by just calling a function to 
which I pass the name of the new page and the text which I want on the page.

I have managed a solution where I just hack directly into the tables 
(bypassing all the mediawiki code), but started to hit code translation type

problems, so I think it is best to do it building on all the wisdom already 
built into the mediawiki code.

The sort of "createPage()" function which I have so far got, but which does 
not work, is as follows:

/**
* Pass the name of the new page and the content and create the page
*/
function createPage($wikiPageName, $pageText) {
  $title = new Title();
  $title = $title->newFromText($wikiPageName);
  $article = new Article($title);
  $article->insertNewArticle($pageText, "No summary", false, false);
}

Anybody done this before?  Any ideas what I need to do specifically to get 
this working?

I have tried to trace through what the "index.php" file does when creating a

page, but it's not easy to follow particularly because of the way in which 
the parameters are often implicit (e.g. via POST of form data).

Thanks for any help!



Hugh Prior 



_______________________________________________
MediaWiki-l mailing list
MediaWiki-l at Wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.0/248 - Release Date: 01/02/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.0/249 - Release Date: 02/02/2006
 




More information about the MediaWiki-l mailing list