Click here to Skip to main content
15,881,413 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: How to convert sample code (available in java, PHP and python) to C# for creating a bot using mediawiki API? Pin
Richard Deeming9-Feb-22 23:09
mveRichard Deeming9-Feb-22 23:09 
QuestionAsp.Net Core. Sending requests with Postman Pin
Kamil Kluska5-Feb-22 22:08
Kamil Kluska5-Feb-22 22:08 
AnswerRe: Asp.Net Core. Sending requests with Postman Pin
Tony Hill6-Feb-22 1:38
mveTony Hill6-Feb-22 1:38 
QuestionExtend Intellisense Pin
101100102-Feb-22 12:28
101100102-Feb-22 12:28 
AnswerRe: Extend Intellisense Pin
Dave Kreskowiak2-Feb-22 13:16
mveDave Kreskowiak2-Feb-22 13:16 
AnswerRe: Extend Intellisense Pin
OriginalGriff2-Feb-22 21:52
mveOriginalGriff2-Feb-22 21:52 
AnswerRe: Extend Intellisense Pin
Gerry Schmitz3-Feb-22 5:48
mveGerry Schmitz3-Feb-22 5:48 
QuestionHi Pin
Dijana Deleva31-Jan-22 9:56
Dijana Deleva31-Jan-22 9:56 
AnswerRe: Hi Pin
Richard MacCutchan31-Jan-22 10:06
mveRichard MacCutchan31-Jan-22 10:06 
AnswerRe: Hi Pin
OriginalGriff31-Jan-22 11:10
mveOriginalGriff31-Jan-22 11:10 
QuestionEF Core - Auto apply migrations with different SQL user Pin
Germghost31-Jan-22 1:33
Germghost31-Jan-22 1:33 
AnswerRe: EF Core - Auto apply migrations with different SQL user Pin
Victor Nijegorodov31-Jan-22 1:54
Victor Nijegorodov31-Jan-22 1:54 
AnswerRe: EF Core - Auto apply migrations with different SQL user Pin
Richard Deeming31-Jan-22 1:54
mveRichard Deeming31-Jan-22 1:54 
QuestionRe: EF Core - Auto apply migrations with different SQL user Pin
Germghost31-Jan-22 2:17
Germghost31-Jan-22 2:17 

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.