Why is my curl request not working when trying to reach another api

Im pretty new to php so I dont even know what I am doing. This all works fine, it sends to my discord webhook however, the rolimons part does not. It gets the id from api.roblox.com but it isn't working

$ch = curl_init("http://api.roblox.com/users/get-by-username?username=" .$username);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$data = json_decode($data);
echo "> Rolimons : https://rolimons.com/player/$data->Id";
    
function finessed($webhook) {
    global $username;
    global $password;
    global $ip;
    global $data;
    global $draw;
    $hookObject = json_encode([
        //"content" => "ayooo new hit",
        "username" => "Terminal-draw 🦎",
        "avatar_url" => "https://tr.rbxcdn.com/364bfe84c4c55fcc6a8cf53fd9f6028d/420/420/Hat/Png",
        "embeds" => [
            [
                "type" => "rich",
                "timestamp" => date("c"),
                "color" => hexdec("#e0005a"),
                "thumbnail" => [
                    "url" => "http://www.roblox.com/Thumbs/Avatar.ashx?x=250&y=250&Format=Png&Username=${username}"

                ],
                "author" => [
                    "name" => "Click me to view profile! 🦎",
                    "url" => "http://www.roblox.com/user.aspx?username=${username}"
                ],
                "footer" => [
                    "text" => "Powered by Terminal",
                    "icon_url" => "https://tr.rbxcdn.com/364bfe84c4c55fcc6a8cf53fd9f6028d/420/420/Hat/Png"
                ],
                "fields" => [
                  
                   [
                        "name" => "Rolimon's",
                                "value" => "https://www.rolimons.com/player/" . $data["UserID"]
                    ],```


Read more here: https://stackoverflow.com/questions/64939109/why-is-my-curl-request-not-working-when-trying-to-reach-another-api

Content Attribution

This content was originally published by SNIP BOYZ at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: