Instagram API - USERNAME SEARCH (LOGINSIZ) // IMGUI DESTEKLI

vt


rgiw85h.png

yazdiginiz kisinin ID sini, biosunu takipci sayisini getirir
ilerde gelistirmeyi dusunuyorum su anlik c++ bilgim bu kadar yetti, http request ve imgui ogrendim
de koy aga bıde
 


rgiw85h.png

yazdiginiz kisinin ID sini, biosunu takipci sayisini getirir
ilerde gelistirmeyi dusunuyorum su anlik c++ bilgim bu kadar yetti, http request ve imgui ogrendim
open source sallarmısın
 
open source sallarmısın
C++:
#pragma comment (lib, "Crypt32.lib")
#pragma comment (lib, "Bcrypt.lib")
#pragma comment (lib, "Secur32.lib")
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Iphlpapi.lib")

#include <iostream>
#include <cpr/cpr.h>
#include <nlohmann/json.hpp>
#define NOMINMAX
#include <windows.h>
#include <thread>
#include <limits>
#include <chrono>
#include "imgui/imconfig.h"
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_opengl3.h"
#include <stdio.h>
#define GL_SILENCE_DEPRECATION

#include <GLFW/glfw3.h>
#pragma comment(lib, "legacy_stdio_definitions")


int main() {
    if (!glfwInit()){
        return 1;
    }
    const char* glsl_version = "#version 130";
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
    glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
    GLFWwindow* window = glfwCreateWindow(1920, 1200, "Instagram Profili", nullptr, nullptr);
    if (window == nullptr) {
        return 1;
    }
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGui::StyleColorsDark();
    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init(glsl_version);

    ImGuiIO& io = ImGui::GetIO();
    ImFontConfig config;
    io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguiemj.ttf", 16.0f, &config, io.Fonts->GetGlyphRangesDefault());
    char username[256] = "";
    bool is_loading = false;
    std::string profile_data = "";
    std::string error_message = "";

    while (!glfwWindowShouldClose(window))
    {

        glfwPollEvents();

        ImGui_ImplOpenGL3_NewFrame();
        ImGui_ImplGlfw_NewFrame();
        ImGui::NewFrame();
        // Pencereyi sürükle
        if (ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowHovered()) {
            int wx, wy;
            glfwGetWindowPos(window, &wx, &wy);
            ImVec2 delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Left);
            glfwSetWindowPos(window, wx + (int)delta.x, wy + (int)delta.y);
            ImGui::ResetMouseDragDelta(ImGuiMouseButton_Left);
        }
        ImGui::Begin("Insta");
        ImGui::InputText("username", username, sizeof(username));

        if (ImGui::Button("Profili Getir")) {
            if (std::string(username).length() > 0) {
                is_loading = true;
                error_message = "";
                profile_data = "";
            }

            try {
                cpr::Response response = cpr::Post(
                    cpr::Url{ "https://instagram120.p.rapidapi.com/api/instagram/profile" },
                    cpr::Body{ R"({"username":")" + std::string(username) + R"("})" },
                    cpr::Header{
                        {"x-rapidapi-key", "63954f4fbbmsh19b337ade3daf56p124f90jsn5d3c85ee1a4d"},
                        {"x-rapidapi-host", "instagram120.p.rapidapi.com"},
                        {"Content-Type", "application/json"}
                    }
                );
                if (response.status_code == 200) {
                    nlohmann::json json_respone = nlohmann::json::parse(response.text);
                    std::string id = json_respone["result"]["id"];
                    std::string username_resp = json_respone["result"]["username"];
                    std::string bio = json_respone["result"]["biography"];
                    long long followers = json_respone["result"]["edge_followed_by"]["count"];

                    profile_data = "ID: " + id + "\n";
                    profile_data += "Username: " + username_resp + "\n";
                    profile_data += "Bio: " + bio + "\n";
                    profile_data += "Followers: " + std::to_string(followers);

                }
                else {
                    error_message = "Hata: " + std::to_string(response.status_code);
                }
            }
            catch (const std::exception& e) {
                error_message = "İstek hatası: " + std::string(e.what());
            }
            is_loading = false;

        }

        if (is_loading) {
            ImGui::Text("Yükleniyor...");

        }
        else if (!error_message.empty()) {
            ImGui::TextColored(ImVec4(1, 0, 0, 1), "Hata: %s", error_message.c_str());
        }
        else if (!profile_data.empty()) {
            ImGui::Text("Sonuç:\n%s", profile_data.c_str());
        }

        ImGui::End();

        ImGui::Render();
        int display_w, display_h;
        glfwGetFramebufferSize(window, &display_w, &display_h);
        glViewport(0, 0, display_w, display_h);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
        glfwSwapBuffers(window);
    }
    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplGlfw_Shutdown();
    ImGui::DestroyContext();
    glfwDestroyWindow(window);
    glfwTerminate();

    return 0;
}
 
C++:
#pragma comment (lib, "Crypt32.lib")
#pragma comment (lib, "Bcrypt.lib")
#pragma comment (lib, "Secur32.lib")
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Iphlpapi.lib")

#include <iostream>
#include <cpr/cpr.h>
#include <nlohmann/json.hpp>
#define NOMINMAX
#include <windows.h>
#include <thread>
#include <limits>
#include <chrono>
#include "imgui/imconfig.h"
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_opengl3.h"
#include <stdio.h>
#define GL_SILENCE_DEPRECATION

#include <GLFW/glfw3.h>
#pragma comment(lib, "legacy_stdio_definitions")


int main() {
    if (!glfwInit()){
        return 1;
    }
    const char* glsl_version = "#version 130";
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
    glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
    GLFWwindow* window = glfwCreateWindow(1920, 1200, "Instagram Profili", nullptr, nullptr);
    if (window == nullptr) {
        return 1;
    }
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);
    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGui::StyleColorsDark();
    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init(glsl_version);

    ImGuiIO& io = ImGui::GetIO();
    ImFontConfig config;
    io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguiemj.ttf", 16.0f, &config, io.Fonts->GetGlyphRangesDefault());
    char username[256] = "";
    bool is_loading = false;
    std::string profile_data = "";
    std::string error_message = "";

    while (!glfwWindowShouldClose(window))
    {

        glfwPollEvents();

        ImGui_ImplOpenGL3_NewFrame();
        ImGui_ImplGlfw_NewFrame();
        ImGui::NewFrame();
        // Pencereyi sürükle
        if (ImGui::IsMouseDragging(ImGuiMouseButton_Left) && ImGui::IsWindowHovered()) {
            int wx, wy;
            glfwGetWindowPos(window, &wx, &wy);
            ImVec2 delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Left);
            glfwSetWindowPos(window, wx + (int)delta.x, wy + (int)delta.y);
            ImGui::ResetMouseDragDelta(ImGuiMouseButton_Left);
        }
        ImGui::Begin("Insta");
        ImGui::InputText("username", username, sizeof(username));

        if (ImGui::Button("Profili Getir")) {
            if (std::string(username).length() > 0) {
                is_loading = true;
                error_message = "";
                profile_data = "";
            }

            try {
                cpr::Response response = cpr::Post(
                    cpr::Url{ "https://instagram120.p.rapidapi.com/api/instagram/profile" },
                    cpr::Body{ R"({"username":")" + std::string(username) + R"("})" },
                    cpr::Header{
                        {"x-rapidapi-key", "63954f4fbbmsh19b337ade3daf56p124f90jsn5d3c85ee1a4d"},
                        {"x-rapidapi-host", "instagram120.p.rapidapi.com"},
                        {"Content-Type", "application/json"}
                    }
                );
                if (response.status_code == 200) {
                    nlohmann::json json_respone = nlohmann::json::parse(response.text);
                    std::string id = json_respone["result"]["id"];
                    std::string username_resp = json_respone["result"]["username"];
                    std::string bio = json_respone["result"]["biography"];
                    long long followers = json_respone["result"]["edge_followed_by"]["count"];

                    profile_data = "ID: " + id + "\n";
                    profile_data += "Username: " + username_resp + "\n";
                    profile_data += "Bio: " + bio + "\n";
                    profile_data += "Followers: " + std::to_string(followers);

                }
                else {
                    error_message = "Hata: " + std::to_string(response.status_code);
                }
            }
            catch (const std::exception& e) {
                error_message = "İstek hatası: " + std::string(e.what());
            }
            is_loading = false;

        }

        if (is_loading) {
            ImGui::Text("Yükleniyor...");

        }
        else if (!error_message.empty()) {
            ImGui::TextColored(ImVec4(1, 0, 0, 1), "Hata: %s", error_message.c_str());
        }
        else if (!profile_data.empty()) {
            ImGui::Text("Sonuç:\n%s", profile_data.c_str());
        }

        ImGui::End();

        ImGui::Render();
        int display_w, display_h;
        glfwGetFramebufferSize(window, &display_w, &display_h);
        glViewport(0, 0, display_w, display_h);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
        glfwSwapBuffers(window);
    }
    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplGlfw_Shutdown();
    ImGui::DestroyContext();
    glfwDestroyWindow(window);
    glfwTerminate();

    return 0;
}
senın o yarran varya onu ben yerım
 

Şuanda konuyu görüntüleyen kullanıcılar

Geri
Üst Alt