[Mediawiki-api] postAPI

Nan Li nan.li at glu.com
Wed Jun 10 09:12:35 UTC 2009


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

      }

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20090610/33c9ddfc/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 38242 bytes
Desc: image001.png
Url : http://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20090610/33c9ddfc/attachment-0001.png 


More information about the Mediawiki-api mailing list