$contact_number,'message' => $message); // $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL,$url); // curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data)); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // $server_output = curl_exec($ch); // curl_close ($ch); // return $server_output; // } public function SmsactiveProvider() { $smsProvider =[]; $db = new db(); $result = $db->sql_query("SELECT code,uri,parameters FROM sms_provider WHERE 1 AND status = 1"); if($result->num_rows ==1) { foreach($result AS $provider){ $smsProvider= $provider; }unset($provider); } return $smsProvider; } public function sendSMS($contact_number, $message,$variable){ $sms = new SMS(); $smsProvider = $sms->SmsactiveProvider(); //get active sms provider $data = array('number' => $contact_number,'message' => $message); $ch = curl_init(); if($smsProvider['code'] =='itexmo') { $itexmo_arr = array( 'Email' => 'aendaya@autohubgroup.com', 'Password' => 'JRE@jre0911', 'ApiCode' => 'PR-AUTOH172111_IE74I', 'SenderId'=> 'AUTOHUB GRP', 'Recipients' => [$data['number']], 'Message' =>$data['message']//$message ); curl_setopt($ch, CURLOPT_URL,$smsProvider['uri']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($itexmo_arr)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // $response = curl_exec($ch); } if($smsProvider['code']=='philsms') { $arr['receiver'] = $data['number']; $arr['message'] = $data['message']; //clean $arr['message'] = strtr($arr['message'], array("\n" => "\\n", "\r" => "\\r")); $arr['message'] = preg_replace('/[\x00-\x1F\x7F\xA0]/u', '', $arr['message']); $arr['uri'] = $variable['sms_api_uri']; $arr['key'] = $variable['sms_api_key']; $arr['pwd'] = $variable['sms_api_password']; $arr['body'] = $variable['sms_api_request_body']; $arr['success'] = $variable['sms_api_success_response']; $arr['http_header'] = $variable['sms_api_http_header']; $replace_parameter = array( '[no]' => $arr['receiver'], '[msg]' => $arr['message'], '[key]' => $arr['key'], '[pwd]' => $arr['pwd'] ); // return $array_data['http_header']; $final_template = strtr($arr['body'], $replace_parameter); // echo'
';print_r($final_template);echo'
'; $headers = json_decode($arr['http_header'], true); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $arr['uri']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $final_template); if (count($headers) > 0) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } // $response = curl_exec($ch); } $result = curl_exec($ch); $response = json_decode($result, true); return $response['status'] == 201 ? 0 : $result; } } ?>