Hi ,All:
The contents of following is the part of my edit page's program.
There are no response if I use this program to modify some pages content , but some pages are ok.
Could you please to help me to look at whether there is something wrong? Thanks.
.....
$post = "title=$name&action=edit&basetimestamp=$ts&starttimestamp=$sts&token=$to ken&summary=$summary$extra&text=$newtext";
$response = $this->postAPI($wiki, 'api.php', $post);
......
private function postAPI($wiki, $url, $postdata = "") {
$wiki = $this->wiki($wiki);
$ch = curl_init();
$url = $wiki . $url;
if ($postdata !== "") {
$postdata .= "&";
}
$postdata .= "format=php&maxlag=" . $this->max_lag;
//echo $url.'?'.$postdata;exit;
//echo "Final postdata: $postdata<br />\n";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded;charset=UTF-8'));
curl_setopt($ch, CURLOPT_HEADER, false);
$response = curl_exec($ch);
//print_r( unserialize($response));exit;
if (curl_errno($ch)) {
return curl_error($ch);
}
curl_close($ch);
return unserialize($response);
}
On Wed, 2009-06-10 at 02:12 -0700, Nan Li wrote:
If you are wanting to use the API from an extension, it would be much easier to do it like this:
http://www.mediawiki.org/wiki/API:Calling_internally
Best Regards
Jools
Thanks .I have add this into my class to edit page. $params = new FauxRequest(array ( 'action' => 'edit', 'title' => $page, 'basetimestamp' => $ts, 'starttimestamp' => $sts, 'token' => $token, 'text' => $newtext )); $api = new ApiMain($params); $api->execute();
$data = & $api->getResultData(); return $data;
and then add this require_once('../../includes/WebRequest.php'); require_once('../../includes/api/ApiMain.php'); at the top of my class.
But there is an error when I access this class.
The error info is : Unsupported operand types in ApiMain.php on line 143 Line 143 is : $this->mModules = $wgAPIModules + self :: $Modules;
Do I need other operations?
-----Original Message----- From: mediawiki-api-bounces@lists.wikimedia.org [mailto:mediawiki-api-bounces@lists.wikimedia.org] On Behalf Of Jools Wills Sent: 2009年6月10日 21:25 To: MediaWiki API announcements & discussion Subject: Re: [Mediawiki-api] postAPI
On Wed, 2009-06-10 at 02:12 -0700, Nan Li wrote:
If you are wanting to use the API from an extension, it would be much easier to do it like this:
http://www.mediawiki.org/wiki/API:Calling_internally
Best Regards
Jools
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2009/6/11 Nan Li nan.li@glu.com:
Thanks .I have add this into my class to edit page. $params = new FauxRequest(array ( 'action' => 'edit', 'title' => $page, 'basetimestamp' => $ts, 'starttimestamp' => $sts, 'token' => $token, 'text' => $newtext ));
$api = new ApiMain($params); $api->execute(); $data = & $api->getResultData(); return $data;
and then add this require_once('../../includes/WebRequest.php'); require_once('../../includes/api/ApiMain.php'); at the top of my class.
Instead of this, you should write your extension as a special page http://www.mediawiki.org/wiki/Manual:Special_pages.
Roan Kattouw (Catrope)
You mean I should create a special page to Call MediaWiki API? Actually I want to find another way to call MediaWiki API. I use curl to post parameters to MediaWikiAPI to edit page. The post parameters are: $post = "title=$page&action=edit&basetimestamp=$ts&starttimestamp=$sts&token=$token&text=$newtext" . Then I use curl to post request. But when the $newtext too long , this request will occur error. Http 500 internal error. So I want to find another way to resolve it.
Could you please give me any help or suggestions? Thanks
-----Original Message----- From: mediawiki-api-bounces@lists.wikimedia.org [mailto:mediawiki-api-bounces@lists.wikimedia.org] On Behalf Of Roan Kattouw Sent: 2009年6月11日 16:51 To: MediaWiki API announcements & discussion Subject: Re: [Mediawiki-api] postAPI
2009/6/11 Nan Li nan.li@glu.com:
Thanks .I have add this into my class to edit page. $params = new FauxRequest(array ( 'action' => 'edit', 'title' => $page, 'basetimestamp' => $ts, 'starttimestamp' => $sts, 'token' => $token, 'text' => $newtext ));
$api = new ApiMain($params); $api->execute(); $data = & $api->getResultData(); return $data;
and then add this require_once('../../includes/WebRequest.php'); require_once('../../includes/api/ApiMain.php'); at the top of my class.
Instead of this, you should write your extension as a special page http://www.mediawiki.org/wiki/Manual:Special_pages.
Roan Kattouw (Catrope)
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2009/6/11 Nan Li nan.li@glu.com:
You mean I should create a special page to Call MediaWiki API? Actually I want to find another way to call MediaWiki API. I use curl to post parameters to MediaWikiAPI to edit page. The post parameters are: $post = "title=$page&action=edit&basetimestamp=$ts&starttimestamp=$sts&token=$token&text=$newtext" . Then I use curl to post request. But when the $newtext too long , this request will occur error. Http 500 internal error. So I want to find another way to resolve it.
Could you please give me any help or suggestions? Thanks
Look in the PHP error log to see what caused the 500.
Roan Kattouw (Catrope)
I found that the page can't be edit by MediaWiki API when it's content have <DPL></DPL> . And then I remove the <DPL></DPL> from this page , it can be edit by MediaWiki API now. Could you please tell me what's the problem for this?
-----Original Message----- From: mediawiki-api-bounces@lists.wikimedia.org [mailto:mediawiki-api-bounces@lists.wikimedia.org] On Behalf Of Roan Kattouw Sent: 2009年6月11日 17:21 To: MediaWiki API announcements & discussion Subject: Re: [Mediawiki-api] postAPI
2009/6/11 Nan Li nan.li@glu.com:
You mean I should create a special page to Call MediaWiki API? Actually I want to find another way to call MediaWiki API. I use curl to post parameters to MediaWikiAPI to edit page. The post parameters are: $post = "title=$page&action=edit&basetimestamp=$ts&starttimestamp=$sts&token=$token&text=$newtext" . Then I use curl to post request. But when the $newtext too long , this request will occur error. Http 500 internal error. So I want to find another way to resolve it.
Could you please give me any help or suggestions? Thanks
Look in the PHP error log to see what caused the 500.
Roan Kattouw (Catrope)
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2009/6/11 Nan Li nan.li@glu.com:
I found that the page can't be edit by MediaWiki API when it's content have <DPL></DPL> . And then I remove the <DPL></DPL> from this page , it can be edit by MediaWiki API now. Could you please tell me what's the problem for this?
This is probably due to a MediaWiki bug that was fixed in 1.15.0, which was released yesterday. Upgrading to 1.15 should fix this.
Roan Kattouw (Catrope)
mediawiki-api@lists.wikimedia.org