3CX Login via PHP

467 views Asked by At

I am trying to log into the 3cx AdminPanel via PHP.

The post url where i have to pass the credentials is

noonecares.com:5001/api/login If I login via browser the request has the following headers:

Content*(request payload)*: {Username: "xxxxx", Password: "xxxxxx"}

In Php I use this headers too

    $opts = [
        "http" => [
            "method" => "POST",
            "header" =>
                "Accept:application/json, text/plain, */*\n\r" .
                "Accept-Encoding:gzip, deflate, br\n\r" .
                "Content-Type:application/json;charset=UTF-8\n\r" .
                "Origin:https://noonecares.com:5001\n\r" .
                "Referer:https://noonecares.com:5001\n\r" .
                "Content-Length:" . strlen($data) . "\n\r",

            "content" => json_encode(["Username" => "xxxxx","Password" => "xxxxxx"]),
        ]
    ];

And I try to send the request with the following code:

    $result = file_get_contents("noonecares.com:5001/api/login", false, stream_context_create($opts));

But I always get "BAD REQUEST" as response and after a couble of tries I get a timeout for around

regards Max

1

There are 1 answers

0
HD-it On

Maybe you can try this:

$opts = [
    "https" => [

instead of

$opts = [
    "http" => [

You can also try this

$result = file_get_contents("https://noonecares.com:5001/api/login", false, stream_context_create($opts));