cURL in WP help

I’m trying to build a custom registration page that makes a call to my .NET API.

    function Test_WBG_Conntection()
    {
        //WBG Object
        $OAuth = new OAuth;
        $OAuth->Administrator = 'username';
        $OAuth->Password = 'password';
        //API URL "http://www.whiteboxgaming.xyz:34188/";
        $url = $endpoint.'api/WhiteBoXGaming/Post_TestAPI';


        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($OAuth));
        $response = curl_exec($ch);

        if($response === FALSE)
        {
            echo "cURL Error" . curl_error($ch);
        }

        curl_close($ch);

        return $response;
    }

Error: cURL ErrorFailed to connect to www.whiteboxgaming.xyz port 34188: Connection refused

Here is my object:
PHP:

                <?php
               class OAuth
               {
                   var $Administrator;
                   var $Password;
               }
            ?>

.Net

                public class OAuth
            {
                public string Administrator { get; set; }
                public string Password { get; set; }
            }

Not sure why its giving an error.This is a working API and I’ve used several different apps with it.

Verify you can reach the API using a tool like postman. I attempted to do so, and the company network has it blocked for malicious content.

yeah i can reach with postman and thats not the real user name or password for testing lol

Is there a syntax error in my code or something else? I’m using notepad++ to write code so no idea if I have errors or not. I’m use to Visual Studio

that could be an issue, I don’t see endpoint defined, even though that string is the endpoint.

I defined it as a class variable i thought. Is there anything else that could be wrong?

I don’t see an issue of why it would refuse the connection, but I would think the auth header should be used for the OAuth not a post field

Sponsor our Newsletter | Privacy Policy | Terms of Service