'; // print_r(json_encode($data)); // echo ''; $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; $validation = get_Auth(); $header = [ "CHI_Authorization :" . $validation ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); if ($response === false) { echo 'Curl error: ' . curl_error($ch); } else { $result = json_decode($response, true); // 若 API 傳入失敗。 if ($result['Status'] == 'Erroe') { echo 'API傳入失敗,' . $result['ErrorMsg']; return $result; } else { // print_r($result); return $result; } } curl_close($ch); } // T8API($data); function pending($user_id, $token) { $api_url = 'localhost:3000/wms/frame/api_getdata'; $data = [ 'p' => 'pending', 'token' => $token ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); if ($response === false) { echo 'Curl error: ' . curl_error($ch); } else { $result = json_decode($response, true); // 若 API 傳入失敗。 if ($result['Status'] == 'Erroe') { echo 'API傳入失敗,' . $result['ErrorMsg']; return $result; } else { echo '
'; print_r($result); echo ''; return $result; } } }