You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
2.4 KiB

<?php
ini_set('display_errors', 'on');
date_default_timezone_set('Asia/Taipei');
$referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : "";
$hashReferer = "https://bpm.masada.com.twMasada@2023";
if ($hashReferer == $referrer) {
include "T8_Authorization_from_bpm.php";
$user_id = "M0000";
$user_password = "M012290493119";
$validation = get_Auth("M0000", "M012290493119");
send_data_to_API($validation);
} else {
echo "非法訪問!";
exit;
}
function send_data_to_API($validation)
{
// $apiurl = 'http://60.244.87.101:880//twWebAPI/V1/STKASSY/PostERPData';
$apiurl = 'http://10.10.145.2:880/twWebAPI/V1/STKASSY/PostERPData';
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKASSY/PostERPData';
$headerParam = [
'CHI_Authorization: ' . $validation,
'Content-Type: application/json'
];
$body = [
[
"name" => "stkAssyMast",
"rows" => [
[
"BillNo" => "TEST06",
"OrgId" => "1000",
"TypeId" => "CA",
"MaterialId" => "3MH00302",
"PersonId" => "M0122",
"CompId" => "1001",
"DeptId" => "220",
"SQuantity" => 1,
"SUnitId" => "SET",
"CurrentState" => 2,
"CreatorId" => "M0122"
]
]
],
[
"name" => "stkAssySubMatInfo",
"rows" => [
[
"BillNo" => "TEST06",
"MaterialId" => "3MH00302P",
"ComponentBaseQty" => 1,
"UnitQty" => 1,
"SUnitId" => "SET",
"MarkerNo" => "3MH00302",
"CU_MaterialId" => "3MH00302"
],
[
"BillNo" => "TEST06",
"MaterialId" => "MX00000001",
"ComponentBaseQty" => 1,
"UnitQty" => 3,
"SUnitId" => "PCS",
"MarkerNo" => "3MH00302",
"CU_MaterialId" => "3MH00302"
]
]
]
];
$json = json_encode($body);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
echo $result['Status'] . "\n";
echo $result['ErrorMsg'] . "\n";
print_r($result['Data']);
}
curl_close($ch);
}