· 6 years ago · Feb 07, 2020, 02:14 PM
1// api data
2 $link = $data_provider['link'];
3 $key = $data_provider['api_key'];
4 // end api data
5 if ($provider == "MANUAL") {
6 $api_postdata = "";
7 } else if ($provider == "LP-PULSA") {
8 $postdata = "key=383fa48c3847c92b27c6e084ec5c456f14daa0142f1589d2ff90d9797ce5a2b62495f166cfd93ee4cc&service=$service_code&target=$post_phone&quantity=$post_quantity&action=order";
9 $ch = curl_init();
10 curl_setopt($ch, CURLOPT_URL, $link);
11 curl_setopt($ch, CURLOPT_POST, 1);
12 curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
13 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
14 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
15 $chresult = curl_exec($ch);
16 curl_close($ch);
17 $json_result = json_decode($chresult, true);
18
19$json_result = json_decode($chresult, true);
20 } else {
21 die("System Error!");
22 }
23
24
25
26 if ($json_result['result'] == FALSE) {
27 $msg_type = "error";
28 $msg_content = 'Yah Gagal!</h4> '.$json_result['error'].'.<script>swal("Ups!", "'.$json_result['error'].'.", "error");</script>';
29 } else {
30
31 if($provider == "LP-PULSA"){
32 $poid = $json_result['data']['id'];
33 $catatan = $json_result['message'];
34 $oid = random_number(5);
35
36
37 }