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.
Photo cc-by-sa @oaldamster.