I am testing the CodeIgniter 3.1 code by making a simple web service.
I found some issue with the response of the API on IFTTT.
The code I have used for the API response in the CI Controller is as below
public function setup()
{
$method = $_SERVER['REQUEST_METHOD'];
$header = $this->input->request_headers();
$IFTTT_Channel_Key = $header["Ifttt-Channel-Key"];
$IFTTT_Service_Key = $header["Ifttt-Service-Key"];
if(
("xyz" === trim($IFTTT_Channel_Key) ) &&
("xyz" === $IFTTT_Service_Key)){
$data = array(
"data" => array(
"accessToken" => "1224124112411",
"samples" => array(
"actions" => array(
"turn_on_light" => array(
"device_name" => "my_device"
)
)
)
)
);
$ci =& get_instance();
$this->output->set_status_header(200);
$ci->output->set_content_type('application/json');
$ci->output->set_output(json_encode($data));
echo json_encode($data);
}
}
The response in the IFTTT Platform :
���{"data":{"accessToken":"1224124112411","samples":{"actions":{"turn_on_light":{"device_name":"my_device"}}}}}
The Response in the Postman tool :
{"data":{"accessToken":"1224124112411","samples":{"actions":{"turn_on_light":{"device_name":"my_device"}}}}}
Note: Please don't edit the question without understanding the actual issue. Please