function sendSMSMessage($to, $txt, $source = '', $msgid = '') { $session = SessionWrapper::getInstance(); $phone = $to; $message = $txt; $sendsms = true; if (isEmptyString($source)) { $source = getSmsSenderName(); } $server = getSmsServer(); $username = getSmsUsername(); $password = getSmsPassword(); $parameters = array('username' => $username, 'password' => $password, 'type' => 'TEXT', 'sender' => $source, 'mobile' => $phone, 'message' => $message); // debugMessage($parameters); $client = new Zend_Http_Client($server, array('adapter' => 'Zend_Http_Client_Adapter_Curl', 'timeout' => 30)); $client->setParameterGet($parameters); // debugMessage($client); // debugMessage(getClientUrl($client)); exit; $smsresult = array(1 => '', 2 => ''); if ($sendsms) { try { //$response = $client->request(); //$body = $response->getBody(); // debugMessage($body); $body = 'SUBMIT_SUCCESS | 53d5cc68-6522-4562-1db4-bee4ae855484'; $msgarray = explode('|', trim($body)); if (!isArrayKeyAnEmptyString('0', $msgarray)) { $smsresult[1] = trim($msgarray[0]); } else { $smsresult[1] = ''; } if (!isArrayKeyAnEmptyString('1', $msgarray)) { $smsresult[2] = trim($msgarray[1]); } else { $smsresult[2] = ''; } // check no of receipients $countphones = count(explode(',', trim($phone))); // save to outbox too $query = "INSERT INTO outbox (phone, msg, source, resultcode, smsid, datecreated, createdby, messageid, msgcount) values ('" . $phone . "', '" . $message . "', '" . $parameters['sender'] . "', '" . $smsresult[1] . "', '" . $smsresult[2] . "', '" . getCurrentMysqlTimestamp() . "', '" . $session->getVar('userid') . "', '" . $msgid . "', '" . $countphones . "') "; // debugMessage($query); $conn = Doctrine_Manager::connection(); $conn->execute($query); return $smsresult; } catch (Zend_Http_Client_Adapter_Exception $e) { # error handling $message = "Error in sending Message: " . $e->getMessage(); debugMessage($message); return array(1 => '', 2 => ''); } } // debugMessage($smsresult); exit; return array(1 => '', 2 => ''); }
function smsTempType4($to, $text) { $param = array('user' => '', 'senderID' => '', 'receipientno' => '', 'msgtxt' => '', 'state' => ''); $info = ''; $param['receipientno'] = $to; $param['msgtxt'] = $text; $param['user'] = getSmsUsername() . ':' . getSmsPassword(); $param['senderID'] = getSmsFeedID(); $param['state'] = 1; foreach ($param as $key => $val) { $info .= $key . "=" . urlencode($val); //we have to urlencode the values $info .= "&"; //append the ampersand (&) sign after each parameter/value pair } $info = substr($info, 0, strlen($info) - 1); return $info; }