Sample code for 30+ languages & platforms
Zig

Woo Commerce Authenticate with Query Params

See more WooCommerce Examples

Demonstrates how to authenticate with Woo Commerce over HTTPS using query params instead of HTTP Basic Authentication.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const http = try chilkat.Http.init();
    defer http.deinit();

    // To authentication over HTTPS using query params, put the query params in the URL.
    const sb_response_body = try chilkat.StringBuilder.init();
    defer sb_response_body.deinit();
    http.quickGetSb("https://example.com/wp-json/wc/v3/products?consumer_key=ck_52bf39999999999999999999999999999996da4d&consumer_secret=cs_6e8bb99999999999999999999999999999997054", sb_response_body) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("Response Body:\n", .{});
    std.debug.print("{s}\n", .{try sb_response_body.getAsString(alloc)});

    const resp_status_code = http.getLastStatus();
    std.debug.print("Response Status Code = {d}\n", .{resp_status_code});
    if (resp_status_code >= 400) {
        std.debug.print("Response Header:\n", .{});
        std.debug.print("{s}\n", .{try http.getLastHeader(alloc)});
        std.debug.print("Failed.\n", .{});
        return;
    }
}