An unofficial AT Protocol SDK for C++
at main 35 lines 930 B view raw
1#include <atpp/client.hpp> 2#include <atpp/lexicons/app/bsky/feed/getFeed.hpp> 3#include <iostream> 4 5using namespace atpp::lexicons; 6 7int main() { 8 try { 9 const char* pds = std::getenv("BSKY_PDS"); 10 atpp::Client client(pds ? pds : "https://bsky.social"); 11 12 const char* handle = std::getenv("BSKY_HANDLE"); 13 const char* password = std::getenv("BSKY_PASSWORD"); 14 15 if (handle && password) { 16 if (!client.login(handle, password)) { 17 std::cerr << "Login failed" << std::endl; 18 return 1; 19 } 20 } 21 22 auto res = client.post("test"); 23 24 if (res) { 25 std::cout << nlohmann::json(res).dump(2) << std::endl; 26 } else { 27 std::cout << "Post failed." << std::endl; 28 } 29 } catch (const std::exception& e) { 30 std::cerr << "Error: " << e.what() << std::endl; 31 return 1; 32 } 33 34 return 0; 35}