Skip to content
Snippets Groups Projects
Commit 77554922 authored by Haidar's avatar Haidar
Browse files

feat: add code rest from soap

parent 3562c155
Branches
Tags
No related merge requests found
<?php <?php
session_start();
include_once __DIR__."/../session.php"; include_once __DIR__."/../session.php";
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
...@@ -12,7 +14,48 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -12,7 +14,48 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$sql = "INSERT INTO user_quest (user_id, quest_id) VALUES ($user_id, $quest_id)"; $sql = "INSERT INTO user_quest (user_id, quest_id) VALUES ($user_id, $quest_id)";
$result = $conn->query($sql); $result = $conn->query($sql);
$username = $_SESSION['username'];
$query = "SELECT * FROM users WHERE username = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("s", $username);
$stmt->execute();
$results = $stmt->get_result();
$row = $results->fetch_assoc();
$UserId = $row['id'];
$requestBody = '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<updatePoint xmlns="http://service.example.org/">
<arg0 xmlns="">' . $UserId . '</arg0>
<arg1 xmlns="">10</arg1>
</updatePoint>
</Body>
</Envelope>';
// echo $requestBody;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '10.97.51.237:8081/updatePoint');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: text/xml; charset="utf-8"',
'X-API-KEY: PHPClient',
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
if ($response === false) {
$error = curl_error($curl);
echo 'Error: ' . $error;
} else {
$responseXml = simplexml_load_string($response);
$returnValue = $responseXml->xpath('//return');
$value = (string) $returnValue[0];
echo $value;
}
echo $sql; echo $sql;
echo "ini bawah sql";
echo $row['id'];
} else { } else {
http_response_code(405); http_response_code(405);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment