Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class myclass
- {
- public function getme(){
- $product_id = 'HGS.10';
- $cust_id = '08128646986';
- // $cust_id = '081233483721';
- $url = 'https://localhost/GATEWAY/DEV_LP_XML/';
- $l_username = base64_encode('TRX.HASYBIEL.06LPTH1356');
- $l_password = base64_encode('12345');
- $trx_id = time();
- $data_input = array(
- 'UID' => $l_username,
- 'PASSWORD' => $l_password,
- 'PRODUCT' => $product_id,
- 'CUST_ID' =>$cust_id,
- 'TRX_ID' => $trx_id
- );
- $data_hasil = json_encode($data_input);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 120);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_hasil;
- $result = curl_exec($ch);
- if ( curl_errno($ch) ) {
- $result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
- } else {
- $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
- switch($returnCode){
- case 404:
- $result = 'ERROR -> 404 Not Found';
- break;
- default:
- break;
- }
- }
- curl_close($ch);
- $res = $result;
- return $res;
- }
- }
- $gets = new myclass();
- var_dump($gets->getme());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement