From b24a6461a2addef136dc2cd17cfa08a998586f3a Mon Sep 17 00:00:00 2001
From: bewe <93899302+bernarduswillson@users.noreply.github.com>
Date: Mon, 13 Nov 2023 14:35:08 +0700
Subject: [PATCH] feat: add call from soap example
---
app/controllers/Merchandise.php | 33 +++++++++++++++++++++++++++++++++
app/views/merchandise/index.php | 3 +++
app/views/question/index.php | 2 +-
3 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 app/views/merchandise/index.php
diff --git a/app/controllers/Merchandise.php b/app/controllers/Merchandise.php
index fe9e196..b9867ea 100644
--- a/app/controllers/Merchandise.php
+++ b/app/controllers/Merchandise.php
@@ -9,6 +9,39 @@ class Merchandise extends Controller
$data["pageTitle"] = "Merch!";
$data["user_id"] = $_SESSION['user_id'];
+ $baseUrl = 'http://10.97.58.62:8080/gems';
+
+ $soapRequest = '<x:Envelope
+ xmlns:x="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ser="http://service.toco.org/">
+ <x:Header/>
+ <x:Body>
+ <ser:getGems>
+ <arg0>1</arg0>
+ </ser:getGems>
+ </x:Body>
+ </x:Envelope>';
+
+ $ch = curl_init($baseUrl);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $soapRequest);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+ 'Content-Type: text/xml',
+ 'SOAPAction: getGems'
+ )
+ );
+
+ $response = curl_exec($ch);
+
+ if (curl_errno($ch)) {
+ echo 'Curl error: ' . curl_error($ch);
+ }
+
+ curl_close($ch);
+ $data['gems'] = $response;
+
+
$this->view('header/index', $data);
$this->view('navbar/index');
$this->view('merchandise/index', $data);
diff --git a/app/views/merchandise/index.php b/app/views/merchandise/index.php
new file mode 100644
index 0000000..b3d5031
--- /dev/null
+++ b/app/views/merchandise/index.php
@@ -0,0 +1,3 @@
+<?php
+echo $data['gems'];
+?>
\ No newline at end of file
diff --git a/app/views/question/index.php b/app/views/question/index.php
index 2989f58..4182ff7 100644
--- a/app/views/question/index.php
+++ b/app/views/question/index.php
@@ -33,7 +33,7 @@
function saveSelectedOption(questionId, optionId) {
const questionKey = questionId.toString();
selectedOption[questionKey] = optionId;
- selectedOption[2] = 5
+ // selectedOption[2] = 5
let listString = Object.entries(selectedOption)
.map(([key, value]) => `${key}:${value}`)
--
GitLab