#define CPPHTTPLIB_OPENSSL_SUPPORT #include #include "httplib/httplib.h" #include "json/include/nlohmann/json.hpp" #include "imgui/imgui.h" #include #include "imgui/backends/imgui_impl_glfw.h" #include "imgui/backends/imgui_impl_opengl3.h" int main() { glfwInit(); GLFWwindow* window = glfwCreateWindow(800, 600, "GithubActiveIMGUI", NULL, NULL); glfwMakeContextCurrent(window); ImGui::CreateContext(); ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init(); char usr[128] = ""; std::vector logs; while (!glfwWindowShouldClose(window)){ glfwPollEvents(); ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); ImGui::SetNextWindowSize(ImVec2(600,400), ImGuiCond_FirstUseEver); ImGui::Begin("Github Active"); ImGui::InputText("Username", usr, 128); if (ImGui::Button("Pull")) { logs.clear(); httplib::Client cli("https://api.github.com"); cli.set_follow_location(true); if (auto response = cli.Get(std::string("/users/") + usr +"/events", httplib::Headers{{"User-Agent", "higithub"}})) { nlohmann::json datas = nlohmann::json::parse(response->body); logs.push_back("Checking for " + std::string(usr)); for (const auto& data : datas){ std::string type = data.value("type", "Unknown"); std::string repo = data.contains("repo") ? data["repo"].value("name", "Unknown") : "Unknown"; std::string date = data.value("created_at", "Unknown"); logs.push_back("[" + date + "] " + type + " -> " + repo); } } else { logs.push_back("Request didnt work :("); } } for (const auto& log : logs) { ImGui::Text("%s", log.c_str()); } ImGui::End(); ImGui::Render(); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); } }