Click here to Skip to main content
15,889,931 members
Home / Discussions / C#
   

C#

 
GeneralMessage Closed Pin
10-Feb-22 0:52
_Q12_10-Feb-22 0:52 
GeneralMessage Closed Pin
10-Feb-22 0:55
_Q12_10-Feb-22 0:55 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
_Q12_10-Feb-22 1:38
_Q12_10-Feb-22 1:38 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
_Q12_10-Feb-22 3:05
_Q12_10-Feb-22 3:05 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
OriginalGriff10-Feb-22 3:58
mveOriginalGriff10-Feb-22 3:58 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
_Q12_15-Feb-22 1:46
_Q12_15-Feb-22 1:46 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
OriginalGriff15-Feb-22 2:15
mveOriginalGriff15-Feb-22 2:15 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
_Q12_9-Feb-22 23:39
_Q12_9-Feb-22 23:39 
AnswerRe: I can not see inside my phone directory branch when I plug it into my PC Pin
trønderen10-Feb-22 6:25
trønderen10-Feb-22 6:25 
GeneralRe: I can not see inside my phone directory branch when I plug it into my PC Pin
Richard Andrew x6410-Feb-22 9:25
professionalRichard Andrew x6410-Feb-22 9:25 
QuestionIt doesn't seem like resizable forms are inheritable Pin
RobertSF9-Feb-22 10:44
professionalRobertSF9-Feb-22 10:44 
AnswerRe: It doesn't seem like resizable forms are inheritable Pin
Eddy Vluggen9-Feb-22 10:59
professionalEddy Vluggen9-Feb-22 10:59 
GeneralRe: It doesn't seem like resizable forms are inheritable Pin
RobertSF9-Feb-22 11:01
professionalRobertSF9-Feb-22 11:01 
GeneralRe: It doesn't seem like resizable forms are inheritable Pin
Eddy Vluggen9-Feb-22 11:08
professionalEddy Vluggen9-Feb-22 11:08 
AnswerRe: It doesn't seem like resizable forms are inheritable Pin
OriginalGriff9-Feb-22 20:09
mveOriginalGriff9-Feb-22 20:09 
GeneralRe: It doesn't seem like resizable forms are inheritable Pin
RobertSF10-Feb-22 5:25
professionalRobertSF10-Feb-22 5:25 
GeneralRe: It doesn't seem like resizable forms are inheritable Pin
OriginalGriff10-Feb-22 5:34
mveOriginalGriff10-Feb-22 5:34 
General[Solved] Re: It doesn't seem like resizable forms are inheritable Pin
RobertSF10-Feb-22 8:29
professionalRobertSF10-Feb-22 8:29 
GeneralRe: [Solved] Re: It doesn't seem like resizable forms are inheritable Pin
OriginalGriff10-Feb-22 9:01
mveOriginalGriff10-Feb-22 9:01 
GeneralRe: [Solved] Re: It doesn't seem like resizable forms are inheritable Pin
RobertSF12-Feb-22 8:59
professionalRobertSF12-Feb-22 8:59 
GeneralRe: [Solved] Re: It doesn't seem like resizable forms are inheritable Pin
OriginalGriff12-Feb-22 9:12
mveOriginalGriff12-Feb-22 9:12 
QuestionHow to convert sample code (available in java, PHP and python) to C# for creating a bot using mediawiki API? Pin
Pallavi H Shinde9-Feb-22 5:57
Pallavi H Shinde9-Feb-22 5:57 
Hello,
I already have a approved bot account on non english wikipedia. I am having trouble with converting the provided sample codes to C#. Would someone kindly do it? More details can be found at API:Tutorial - MediaWiki[^] and API:Edit - MediaWiki[^] Samples in java, PHP and python can be found at "API:Edit - MediaWiki" link. Here is sample code in java:

/*  
    edit.js
 
    MediaWiki API Demos
    Demo of `Edit` module: POST request to edit a page

    MIT license
*/

var request = require('request').defaults({jar: true}),
    url = "https://test.wikipedia.org/w/api.php";

// Step 1: GET request to fetch login token
function getLoginToken() {
    var params_0 = {
        action: "query",
        meta: "tokens",
        type: "login",
        format: "json"
    };

    request.get({ url: url, qs: params_0 }, function (error, res, body) {
        if (error) {
            return;
        }
        var data = JSON.parse(body);
        loginRequest(data.query.tokens.logintoken);
    });
}

// Step 2: POST request to log in. 
// Use of main account for login is not
// supported. Obtain credentials via Special:BotPasswords
// (https://www.mediawiki.org/wiki/Special:BotPasswords) for lgname & lgpassword
function loginRequest(login_token) {
    var params_1 = {
        action: "login",
        lgname: "bot_username",
        lgpassword: "bot_password",
        lgtoken: login_token,
        format: "json"
    };

    request.post({ url: url, form: params_1 }, function (error, res, body) {
        if (error) {
            return;
        }
        getCsrfToken();
    });
}

// Step 3: GET request to fetch CSRF token
function getCsrfToken() {
    var params_2 = {
        action: "query",
        meta: "tokens",
        format: "json"
    };

    request.get({ url: url, qs: params_2 }, function(error, res, body) {
        if (error) {
            return;
        }
        var data = JSON.parse(body);
        editRequest(data.query.tokens.csrftoken);
    });
}

// Step 4: POST request to edit a page
function editRequest(csrf_token) {
    var params_3 = {
        action: "edit",
        title: "Project:Sandbox",
        appendtext: "test edit",
        token: csrf_token,
        format: "json"
    };

    request.post({ url: url, form: params_3 }, function (error, res, body) {
        if (error) {
            return;
        }
        console.log(body);
    });
}

// Start From Step 1
getLoginToken();


Thanks a lot in advance.

modified 9-Feb-22 12:08pm.

AnswerRe: How to convert sample code (available in java, PHP and python) to C# for creating a bot using mediawiki API? Pin
Eddy Vluggen9-Feb-22 6:01
professionalEddy Vluggen9-Feb-22 6:01 
GeneralRe: How to convert sample code (available in java, PHP and python) to C# for creating a bot using mediawiki API? Pin
Pallavi H Shinde9-Feb-22 7:09
Pallavi H Shinde9-Feb-22 7:09 
GeneralRe: How to convert sample code (available in java, PHP and python) to C# for creating a bot using mediawiki API? Pin
Eddy Vluggen9-Feb-22 8:03
professionalEddy Vluggen9-Feb-22 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.