Ошибка: не удалось подключиться к порту 80 alenke.test: соединение отказался
но когда я выполняю его в терминале
Код: Выделить всё
curl --ipv4 -v "http://alenke.test/wp-json/chatbot/v1/brand";
Код: Выделить всё
`Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to alenke.test (127.0.0.1) port 80 (#0)
GET /wp-json/chatbot/v1/brand HTTP/1.1
Host: alenke.test
User-Agent: curl/7.54.0
Accept:
HTTP/1.1 200 OK
Server: nginx/1.15.7
Date: Sun, 01 Sep 2019 16:47:36 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/7.3.7
X-Robots-Tag: noindex
Link: ; rel="https://api.w.org/"
X-Content-Type-Options: nosniff Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages Access-Control-Allow-Headers: Authorization, Content-Type Allow: GET `
Код: Выделить всё
function callAPI($method, $url, $data){
$curl = curl_init();
switch ($method){
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// OPTIONS:
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "admin:admin");
// EXECUTE:
$result = curl_exec($curl);
if(!$result){
if (curl_errno($curl)) {
echo 'Error: ' . curl_error($curl);
echo'//;
echo print_r(curl_getinfo($curl));
echo'//;
die("Connection Failure..?");
}
}
curl_close($curl);
return $result;
}
Ошибка: не удалось подключиться к аленке. тестовый порт 80: соединение отклонено
Подробнее здесь: https://stackoverflow.com/questions/577 ... to-port-80
Мобильная версия