Unofficial Medium API client library for Vala. Still a work in progress.
I recommend including medium-vala
as a git submodule and adding medium-vala/src/Medium.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 medium-vala/src/Medium3.vala
.
meson
ninja-build
valac
libgtk-3-dev
meson build
cd build
meson configure -Denable_examples=true
ninja
./examples/hello-medium
Examples require update to username and password, don't check this in
string user = "username";
string password = "password";
string user = "user";
string key = "integration-key";
Medium.Client client = new Medium.Client ();
if (client.authenticate (
user,
key))
{
print ("Successfully logged in");
} else {
print ("Could not login");
}
string my_username;
if (client.get_authenticated_user (out my_username)) {
print ("Logged in as: %s", my_username);
}
string url;
string id;
if (client.publish_post (
out url,
out id,
"# Hello Medium!
Hello from [ThiefMD](https://thiefmd.com)!",
"Hello Medium!"))
{
print ("Made post: %s", url);
}
string file_url = "";
if (client.upload_image_simple (
out file_url,
"/home/user/Pictures/photo.png"
))
{
print ("Uploaded: %s", file_url);
}