Using Soup to Post in Vala

avatar

As an https request.

Publishing quick and dirty, while I am cooking a real meal, actually.

Beyond Hello World...

This is not a tutorial on how to use the Vala Trans-Compiling language. It is merely an experience blog, while I dive into the debts of Val(hal)a. Easy as pie? So far I like programming in Vala. Not a programmer, just a geek having a good time exploring new innovative technologies.

Make sure you have VALA installed and all its dependencies, plus the 'soup lib' (In Nederish that sounds funny.) Compile it with 'valac' and remember to add '-pgk libsoup-2.4'. After that just run it './soeper'. There you go, a small step, but there lies potential in it.

\FILE::soeper/vala

/** 
    * Use SOUP to POST *
**/

using Soup;

public static int main () {
    
    var uri = "https://api.steemit.com";
    var session = new Soup.Session ();
    var message = new Soup.Message ("POST", uri);
    var contentType = "Content-Type: application/json:";
    var postIt = "{\"jsonrpc\":\"2.0\", \"method\":\"condenser_api.get_accounts\", \"params\":[[\"oaldamster\"]], \"id\":1}";

    /**
        * Please note 'postIt' needs to be in INT8[] format, not a string! *
    **/
    message.set_request(contentType, MemoryUse.COPY, postIt.data);

    session.send_message (message); 

    // Show response
    stdout.printf("%s \n", (string) message.response_body.flatten ().data);

    return 0; 
}

/FILE::soeper.vala

Commandline

valac soeper.vala --pkg libsoup-2.4

RUN

./soeper


That sureaint no Soup... But quite tasty.
photo5931552288105672863.jpg
Photo cc-by-sa @oaldamster.



0
0
0.000
1 comments
avatar

According to the Bible, Charity Means Love (4 of 5)

(Sorry for sending this comment. We are not looking for our self profit, our intentions is to preach the words of God in any means possible.)



Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to Thank you, our beloved friend.
Check our Discord Chat
Join our Official Community: https://beta.steemit.com/trending/hive-182074

0
0
0.000