Re: Wikibot code

edit

You can put the files anywhere, so long as you can run them using php. Mostly you would put them on a webserver.

Logging into a non-Wikimedia wiki (where http://foo.com/w/ is the first part of a working http://foo.com/w/api.php address):

<?php
  //grab class
  include('Wikibot.php5');
  //get password
  $password = file_get_contents("password.txt") or die("Can't open password file");
  //create bot
  $username = "MyBot"; //A registered username
  $MyBot = new Wikibot($username, $password, 'http://foo.com/w/');
?>

To change content you use PHP's own functions:

<?php
  //grab class
  include('Wikibot.php5');
  //get password
  $password = file_get_contents("password.txt") or die("Can't open password file");
  //create bot
  $username = "MyBot"; //A registered username
  $MyBot = new Wikibot($username, $password);
  $text = $MyBot->get_page("Cheese");
  $text = str_replace( "wrongword", "correctword", $text );
  $MyBot->edit_page("Cheese",$text,"Replacing wrongword with correctword");
?>

Hope that helps, - Jarry1250 [Weasel? Discuss.] 11:06, 23 August 2011 (UTC)Reply

Really? Virtually all packages support PHP. Are you familiar with PHP? What errors are you getting? - Jarry1250 [Weasel? Discuss.] 11:14, 23 August 2011 (UTC)Reply
Is it literally FTP only? It's just a storage space rather than a webserver? If so, you'd probably be best off downloading PHP (either standalone or as part of a package such as XAMPP) and tying to run everything locally from the command line. It might be that good PHP webserver hosting support is available for free somewhere though. - Jarry1250 [Weasel? Discuss.] 11:26, 23 August 2011 (UTC)Reply
Okay, at least it's processing the file. Which one is line 36? (I don't have the line numbers in front of me.) - Jarry1250 [Weasel? Discuss.]
Well if you get back to at least having it execute the file, put in "print_r( $result );" immediately before the contentious line, and copy me the output. Thanks, - Jarry1250 [Weasel? Discuss.] 12:02, 23 August 2011 (UTC)Reply
Ah, xampp's default settings are a little odd. There should be no need to change Wikibot.php, just use the code snippets above in a separate file in the same directory, changing the "foo.com" URL above for "http://www.uesp.net/w/". - Jarry1250 [Weasel? Discuss.] 15:54, 23 August 2011 (UTC)Reply
Evidently changing to .php is thje best strategy. Did you get it working then? - Jarry1250 [Weasel? Discuss.] 09:40, 24 August 2011 (UTC)Reply