我正试图通过PHP登录到3 3cx AdminPanel。
我必须通过证书的帖子url是
noonecares.com:5001/api/login如果我通过浏览器登录,请求具有以下标题:
Content*(request有效载荷)*:{用户名:"xxxxx",密码:"xxxxxx"}
在Php中,我也使用这个标头
$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"]),
]
];我尝试用以下代码发送请求:
$result = file_get_contents("noonecares.com:5001/api/login", false, stream_context_create($opts));但是我总是收到“糟糕的请求”作为回应,在尝试之后,我得到了一个暂停。
问候麦克斯
发布于 2017-09-04 07:52:29
也许你可以试试这个:
$opts = [
"https" => [而不是
$opts = [
"http" => [你也可以试试这个
$result = file_get_contents("https://noonecares.com:5001/api/login", false, stream_context_create($opts));https://stackoverflow.com/questions/45233535
复制相似问题