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);
}