Hi,
I'm trying to edit pages through the api using PHP Curl and every
created/edited page gets api.php as page title and completely ignores my
custom title passed in as parameter!
Any ideas?
Thanks in advance!
Here's a sample of my code :
private function runCurlCall($url,$postValue,$method)
{
$curl_data = http_build_query($postValue);
print $url ."?". $curl_data."<br>";
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_FRESH_CONNECT => true,
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 20, // stop after 10 redirects
CURLOPT_POST => 1, // i am sending post data
CURLOPT_POSTFIELDS => $curl_data, // this are my post vars
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
CURLOPT_SSL_VERIFYPEER => false, //
CURLOPT_VERBOSE => true
);
$ch = curl_init($url);
curl_setopt_array($ch,$options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch) ;
$header = curl_getinfo($ch);
curl_close($ch);
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
public function editPage()
{
$args = array( "action"=>"query",
"prop"=>"info|revisions",
"intoken"=>"edit",
"titles"=>"Talk:Main_Page",
"format"=>"xml"
);
$xml = $this->runCall($this->api_url, $args, __METHOD__);
$edittoken =
$this->cleanXmlString($xml->query->pages->page['edittoken']);
$args = array( "action"=>"edit",
"title"=>"Talk:Main_Page",
"summary"=>"test",
"text"=>"yesssss",
"format"=>"xml",
"token"=>$edittoken
);
$xml = $this->runCurlCall($this->api_url, $args, __METHOD__);
print_r($xml);
}
Show replies by date
On Mon, Nov 29, 2010 at 8:46 PM, Bruno Caillé <bcaille(a)k3media.com> wrote:
Hi,
I'm trying to edit pages through the api using PHP Curl and every
created/edited page gets api.php as page title and completely ignores my
custom title passed in as parameter!
Any ideas?
Is the server you are accessing configured to use short urls? If so,
can you show its .htaccess?
Bryan
Yes it is.
Here's the code :
RewriteEngine On
RewriteBase /mediawiki
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mediawiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA]
Bruno
On 10-11-29 03:28 PM, Bryan Tong Minh wrote:
On Mon, Nov 29, 2010 at 8:46 PM, Bruno
Caillé<bcaille(a)k3media.com> wrote:
Hi,
I'm trying to edit pages through the api using PHP Curl and every
created/edited page gets api.php as page title and completely ignores my
custom title passed in as parameter!
Any ideas?
Is the server you are accessing configured to use short urls? If so,
can you show its .htaccess?
Bryan
_______________________________________________
Mediawiki-api mailing list
Mediawiki-api(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Thanks Bryan,
Tried disabling rewriting and the problem still exists.
Found a working workaround here.
http://www.mediawiki.org/wiki/Talk:API#Problems_with_action.3Dedit
Bruno
On 10-11-29 03:28 PM, Bryan Tong Minh wrote:
On Mon, Nov 29, 2010 at 8:46 PM, Bruno
Caillé<bcaille(a)k3media.com> wrote:
Hi,
I'm trying to edit pages through the api using PHP Curl and every
created/edited page gets api.php as page title and completely ignores my
custom title passed in as parameter!
Any ideas?
Is the server you are accessing configured to use short urls? If so,
can you show its .htaccess?
Bryan
_______________________________________________
Mediawiki-api mailing list
Mediawiki-api(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
On Mon, Nov 29, 2010 at 2:51 PM, Bruno Caillé <bcaille(a)k3media.com> wrote:
Thanks Bryan,
Tried disabling rewriting and the problem still exists.
Found a working workaround here.
http://www.mediawiki.org/wiki/Talk:API#Problems_with_action.3Dedit
You're probably rewriting into the same path that the files are installed to.