Thanks I was just about to reply to you and say that I got it working
with cookies. Interesting that I can't get it to work with the tokens.
It must believe the session is ended when doing it without cookies.
---Working PHP Edit Code---
echo "<pre>";
print_r($_POST);
$apiURL =
"http://".$_SERVER['HTTP_HOST']."/phpapps/wiki/api.php";
$loginURL =
array("action"=>"login","lgname"=>"jkuter","lgpassword"=>"","lgdomain"=>
"ad.mathworks.com","format"=>"php");
$getLoginResponse = unserialize(getURL($apiURL,$loginURL));
print_r($getLoginResponse);
$titleURLParams =
array("action"=>"query","prop"=>"info","titles"=>"BatPresubmitTest","int
oken"=>"edit","format"=>"php");
print_r($titleURLParams);
$getTitleResponse = unserialize(getURL($apiURL,$titleURLParams));
print_r($getTitleResponse);
//$newPageURLParams =
array("action"=>"query","prop"=>"info","titles"=>"BatPresubmitTest","int
oken"=>"edit",
//
"lgtoken"=>$getLoginResponse['login']['lgtoken'],"lgusername"=>$getLogin
Response['login']['lgusername'],
//
"lguserid"=>$getLoginResponse['login']['lguserid'],"format"=>"php");
//$makeNewPage = unserialize(getURL($apiURL,$newPageURLParams));
//print_r($makeNewPage);
echo "</pre>";
function getURL($url,$vars){
include "Snoopy.class.php";
$snoopy = new Snoopy;
$snoopy->cookies["inside_wikiToken"] =
$_COOKIE["inside_wikiToken"];
$snoopy->cookies["inside_wikiUserID"] =
$_COOKIE["inside_wikiUserID"];
$snoopy->cookies["inside_wikiUserName"] =
$_COOKIE["inside_wikiUserName"];
$snoopy->cookies["inside_wiki_session"] =
$_COOKIE["inside_wiki_session"];
$snoopy->submit($url,$vars);
$snoopy->setcookies();
return $snoopy->results;
}
---End Working PHP Code---
-----Original Message-----
From: Roan Kattouw [mailto:roan.kattouw@home.nl]
Sent: Tuesday, November 13, 2007 12:23 PM
To: Jason Kuter
Subject: Re: [Mediawiki-api] FW: Problems Using API Via PHP
Jason Kuter schreef:
Understood, I just wish it worked without an
additional class. Using
Snoopy works but my user is not being authenticated. It must be
another
issue.
Thanks for the reply,
jason
Use $snoopy->setCookies(); after doing action=login to force Snoopy to
remember the authentication cookies.
Roan Kattouw (Catrope)