Something went wrong. Try again.
An unofficial AT Protocol SDK for C++.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#include <atpp/client.hpp>#include <atpp/richtext.hpp>#include <iostream>
using namespace atpp::lexicons;
int main(int argc, char* argv[]) { try { const char* pds = std::getenv("BSKY_PDS"); atpp::Client client(pds ? pds : "https://bsky.social");
const char* handle = std::getenv("BSKY_HANDLE"); const char* password = std::getenv("BSKY_PASSWORD");
if (handle && password) { if (!client.login(handle, password)) { std::cerr << "Login failed." << std::endl; return 1; } } else { std::cerr << "Handle or password not set." << std::endl; return 1; }
app::bsky::feed::post::Main record; record.text = "Hello from AT++"; if (argc > 1) { record.text = ""; for (int i = 1; i < argc; ++i) { if (i > 1) record.text += " "; record.text += argv[i]; } } auto facets = atpp::richtext::detectFacets(record.text, [&](const std::string& h) -> std::optional<std::string> { try { auto r = client.resolveHandle(h); if (r) return r->did; } catch (...) {} return std::nullopt; }); record.facets = facets; auto res = client.post(record);
if (res) { std::cout << nlohmann::json(res).dump(2) << std::endl; } else { std::cout << "Post failed." << std::endl; } } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; }
return 0;}