duanmu2015 2019-03-04 08:15
浏览 50

CodeIgniter在IFTTT上返回未知响应

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题