making_a_http_request

# Making Arbitrary HTTP Requests Using D++

If you wish to make arbitrary HTTP(S) requests to websites and APIs, e.g. to update statistics on bot lists, you can use code similar to the code below. You may pass any arbitrary POST data:

    #include<dpp/dpp.h>
    #include<iostream>

    intmain(){
    dpp::clusterbot("token");

    bot.on_log(dpp::utility::cout_logger());

    bot.on_ready([&bot](constdpp::ready_t&event){
    //Arbitrarypostdataasastring
    std::stringmypostdata="{\"value\":42}";
    //MakeaHTTPPOSTrequest.HTTPandHTTPSaresupportedhere.
    bot.request(
    "http://www.somebotlist.com/api/servers",dpp::m_post,[](constdpp::http_request_completion_t&cc){
    //ThiscallbackiscalledwhentheHTTPrequestcompletes.Seedocumentationof
    //dpp::http_request_completion_tforinformationonthefieldsintheparameter.
    std::cout<<"Igotreply:"<<cc.body<<"withHTTPstatuscode:"<<cc.status<<"\n";
    },
    mypostdata,
    "application/json",
    {
    {"Authorization","Bearertokengoeshere"}
    }
    );
    });

    bot.start(dpp::st_wait);

    return0;
    }