Skip to content

Latest commit

 

History

History
79 lines (60 loc) · 1.4 KB

README.md

File metadata and controls

79 lines (60 loc) · 1.4 KB

forem-vala

Unofficial Forem API client library for Vala. Still a work in progress.

Compilation

I recommend including forem-vala as a git submodule and adding forem-vala/src/Forem.vala to your sources list. This will avoid packaging conflicts and remote build system issues until I learn a better way to suggest this.

For libsoup3, use forem-vala/src/Forem3.vala.

Requirements

meson
ninja-build
valac

Building

meson build
cd build
meson configure -Denable_examples=true
ninja
./examples/hello-forem

Examples require update to username and API key, don't check this in

string user = "username";
string key = "api-key";

Quick Start

New Login

string user = "user";
string key = "api-key";

Forem.Client client = new Forem.Client ("https://dev.to/");
if (client.authenticate (
        user,
        key))
{
    print ("Successfully logged in");
} else {
    print ("Could not login");
}

Check Logged in User

string my_username;
if (client.get_authenticated_user (out my_username)) {
    print ("Logged in as: %s", my_username);
}

Publish a Post

string url;
string id;
if (client.publish_post (
    out url,
    out id,
    "# Hello Forem!

Hello from [ThiefMD](https://thiefmd.com)!",
    "Hello Forem!"))
{
    print ("Made post: %s", url);
}