Hi Hiren,
when i direct open my server (http://server.quizo.net/ ) its gives me this error:
This site can’t be reached
or when i try to run with ip: http://185.37.226.102/
Not Found
The requested URL / was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
can u please tell me is it server issues or in my coding issues?
my code is:
$username = “ravi”;
$url = “http://185.37.226.102:9090/plugins/restapi/v1/users/”.$username; // get All Users
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_PORT, 5269);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(“Accept: application/json”, “Authorization: Basic YaWRtaW46Y5sWRtaW4xMjMKta”));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, “GET”);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check for errors and display the error message
if($errno = curl_errno($curl)) {
$error_message = curl_strerror($errno);
echo “cURL error ({$errno}):\n {$error_message}”;
}
curl_close($curl);
$response = json_decode($json_response);
echo “
”; print_r($response); die(“check status”);
one thing more, this code is working in postman and gives the result.
even when i wrote this code in file_get_contents, in its also work.
but curl is not work. may i know the reason?
with file_get_contents:
<?php
$url = "http://185.37.226.102:9090/plugins/restapi/v1/users/vanny";
$options = array(
'http' => array(
"method" => "GET",
'header' => array("Accept: application/json", "Authorization: Basic YaWRtaW46Y5sWRtaW4xMjMKta")
),
);
$context = stream_context_create($options);
//var_dump($context);
// Open the file using the HTTP headers set above
$result = file_get_contents($url, false, $context);
echo "";
$jsonRes = json_decode($result);
if(isset($jsonRes)){
echo "user exist";
} else {
echo "not exist";
}
?>