发布后请求XML无法显示

时间:2019-08-08 05:46:19

标签: php xml api codeigniter curl

我正在尝试将$ noKartu,$ tglSep,$ noMR,$ tglRujukan,$ noRujukan,$ ppkRujukan,$ diagAwal,$ tujuan发布到具有XML格式的CURL,但以$ scml(请求xml格式)变量$ noKartu等上面没有找到。有人可以帮我吗?

这是我的控制器:

public function cetak_sep() {
        {
            //post input data dari form
            date_default_timezone_set('Asia/Jakarta');
            $tglSep = date('Y-m-d');
            $noKartu = $this->input->post('noKartu');
            $tglRujukan = $this->input->post('tglRujukan');
            $noRujukan = $this->input->post('noRujukan');
            $ppkRujukan = $this->input->post('ppkRujukan');
            $diagAwal = $this->input->post('diagAwal');
            $tujuan = $this->input->post('tujuan');
            $kodeDPJP = $this->input->post('kodeDPJP');
            $noMR = $this->input->post('noMR');
            $noTelp = $this->input->post('noTelp');

            $scml = '
            {
               "request": {
                  "t_sep": {
                     "noKartu": "'.$noKartu.'",
                     "tglSep": "'.$tglSep.'",
                     "ppkPelayanan": "0112R060",
                     "jnsPelayanan": "2",
                     "klsRawat": "3",
                     "noMR": "'.$noMR.'",
                     "rujukan": {
                        "asalRujukan": "1",
                        "tglRujukan": "'.$tglRujukan.'",
                        "noRujukan": "'.$noRujukan.'",
                        "ppkRujukan": "'.$ppkRujukan.'"
                     },
                     "catatan": "-",
                     "diagAwal": "'.$diagAwal.'",
                     "poli": {
                        "tujuan": "'.$tujuan.'",
                        "eksekutif": "0"
                     },
                     "cob": {
                        "cob": "0"
                     },
                     "katarak": {
                        "katarak": "0"
                     },
                     "jaminan": {
                        "lakaLantas": "0",
                        "penjamin": {
                            "penjamin": "null",
                            "tglKejadian": "null",
                            "keterangan": "null",
                            "suplesi": {
                                "suplesi": "0",
                                "noSepSuplesi": "null",
                                "lokasiLaka": {
                                    "kdPropinsi": "null",
                                    "kdKabupaten": "null",
                                    "kdKecamatan": "null"
                                    }
                            }
                        }
                     },
                     "skdp": {
                        "noSurat": "-",
                        "kodeDPJP": "'.$kodeDPJP.'"
                     },
                     "noTelp": "'.$noTelp.'",
                     "user": "admin.tebet"
                  }
               }
            } 
            ';

            //cons.id dan secretKey dari BPJS
            $cons_id = "19597"; //Ganti dengan consumerID dari BPJS
            $secretKey = "1sU3D5470D"; //Ganti dengan consumerSecret dari BPJS

            date_default_timezone_set('UTC');
            $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
            $signature = hash_hmac('sha256', $cons_id."&".$tStamp, $secretKey, true);
            $encodedSignature = base64_encode($signature);

            $arrheader = array(
                'X-cons-id: '.$cons_id,
                'X-timestamp: '.$tStamp,
                'X-signature: '.$encodedSignature,
                'Content-type: Application/x-www-form-urlencoded',
            );

            $url = 'https://dvlp.bpjs-kesehatan.go.id/VClaim-Rest/SEP/1.1/insert';  //Lihat katalog

            $process = curl_init($url);

            curl_setopt($process, CURLOPT_URL, $url);
            curl_setopt($process, CURLOPT_VERBOSE, true);
            curl_setopt($process, CURLOPT_TIMEOUT,30);
            curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($process, CURLOPT_HTTPHEADER, $arrheader);
            curl_setopt($process, CURLOPT_POST, true);
            curl_setopt($process, CURLOPT_POSTFIELDS, $scml);

            $return = curl_exec($process);
            curl_close($process);

            $response = json_decode($return, true);

            if ($response['metaData']['message']!="Sukses"){
                echo $response['metaData']['message'];
            } else {
                echo $response['response']['sep']['noSep'];
            }
        }

我认为格式XML请求没有问题,发布后,没有($ noKartu等)值

0 个答案:

没有答案