使用 php 和 curl 更新 mediawiki (using php and curl to update mediawiki)


問題描述

使用 php 和 curl 更新 mediawiki (using php and curl to update mediawiki)

I've been working on a php script to update mediawiki entries, however whenever I run it it doesn't seem to update the wiki at all and just returns the article page unedited.

I've included a section which logs into the wiki first and I've successfully read information off the wiki but I have not been able to update it.

Is there something I'm missing or better yet is there an existing php package which can be used to update a mediawiki.  

thanks in advance,

sample code follows:

function curl_post_page($site, $post ) {
$headers = array();
$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 

//var_dump($post);
$cl = curl_init($site);
curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($cl, CURLOPT_HEADER, true);
curl_setopt($cl, CURLOPT_VERBOSE, true);
curl_setopt($cl, CURLOPT_FAILONERROR, true); 
curl_setopt($cl, CURLOPT_POST, TRUE);
curl_setopt($cl, CURLOPT_POSTFIELDS, $post);
curl_setopt($cl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($cl, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)");
curl_setopt($cl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cl, CURLOPT_COOKIEFILE, "cookie.txt");

參考解法

方法 1:

There are several client libraries available (known good revision | mirror at archive.org)

方法 2:

Is the api writing enabled? ($wgEnableWriteAPI = false;) It is disabled by default for versions below 1.14.

Are you getting any errors back? 

(by Snap_DragonFrank FarmerAdrian Archer)

參考文件

  1. using php and curl to update mediawiki (CC BY-SA 3.0/4.0)

#curl #post #mediawiki #PHP






相關問題

如何在所有 PayPal 交易中退還費用 (How to return fee in all PayPal transactions)

Cú pháp lệnh curl để đăng ký device_token trên Urban Airship là gì? (What is curl command syntax for device_token registration on Urban Airship?)

Nhận thời lượng video trên youtube từ URL với bash (Get youtube video duration from URL with bash)

đăng dữ liệu json với php curl cho đa phần / dữ liệu biểu mẫu để tải lên tệp nếu cakephp 2 (post json data with php curl for multipart/form-data for file upload vía cakephp 2)

ApacheMonitor 上的捲曲錯誤 (Curl error on ApacheMonitor)

從 ASP.net 使用 PHP 中的 POST 數據抓取數據 (Scraping data with POST data in PHP from ASP.net)

收聽推送消息? (Listen to a push message?)

在 PHP 中使用 cURL 的 RAW POST (RAW POST using cURL in PHP)

使用 php 和 curl 更新 mediawiki (using php and curl to update mediawiki)

在 Makefile 中鏈接 cURL (Linking cURL in Makefile)

將我的 .php 輸出發送到 curl 命令,該命令使用機器人在電報上向我發送消息 (Send my .php output to a curl command that messages me on telegram using a bot)

使用 Google My Business API 和 PHP 更新/修補本地帖子 (Updating/Patching a Local Post with Google My Business API and PHP)







留言討論