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:
- Accept:application/json, text/plain, /
- Content-Type:application/json;charset=UTF-8
- Content-Length: #CONTENT_LENGTH#
- Accept-Encoding:gzip, deflate, br
- Origin:https://noonecares.com:5001
- Referer:https://noonecares.com/
- X-3CX-Version:15.5.1694.0
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
Maybe you can try this:
instead of
You can also try this