<?php
//build data parameters
$data = array(
'name' => 'foo',
'phone_no' => '39327774645',
'password' => 'kdjfkff'
);
//request header
$headers = array(
"Accept: application/json",
"X-HTTP-Method-Override: POST"
);
//CURL initialization with URL, Method, Header and Parameters
$url = "https://194.244.57.4/api_friends/v1/register";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
//SEND request
$response = curl_exec($curl);
//read the result
$json = json_decode($response, true);
//print different array element
echo "ERROR: " . $json['error'] ."\n"; // true o false
echo "MSG: " . $json['message'] ."\n"; // Operation completed!
echo "STATUS: " .$json['status'] ."\n"; // 200
//print all array
echo print_r ($json);
//other optional actions
if ($json['status'] == '200') {
echo "OK";
//...
} else {
echo "FAILED";
//...
}
?>
preferences:
30.59 ms | 402 KiB | 5 Q