login=$param_list["login"]; $this->password=$param_list["password"]; $this->tpoa=$param_list["tpoa"]; if ($param_list["messageQty"]) { $this->messageQty=$param_list["messageQty"]; } if ($param_list["messageType"]) { $this->messageType=$param_list["messageType"]; } } public function send_sms($telephone, $message) { global $charset; $telephone = preg_replace("/.[^0-9]/", "", $telephone); $telephone = preg_replace("/^[\+|[^0-9]]/", "", $telephone); if (substr($telephone, 0, 1) == "0") { $telephone = "+33" . substr($telephone, 1); } else if (substr($telephone, 0, 1) != "+") { return false; } $fields=array( "login"=>$this->login, "password"=>$this->password, "mobile"=>$telephone, "messageQty"=>$this->messageQty, "messageType"=>$this->messageType, "tpoa"=>$this->tpoa, //$object_message, "message"=>$message ); if (strtoupper($charset) != "UTF-8") { foreach ($fields as $key => $val) { $fields[$key] = encoding_normalize::utf8_normalize($val); } } foreach ($fields as $key=>$val) $post[]=$key."=".rawurlencode($val); $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.smstrend.net/fra/sendMessageFromPost.oeg"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, implode("&",$post)); $r=curl_exec($ch); curl_close($ch); if($r=="OK") return true; return false; } } class sms_rouenbs { private $ws; private $from=''; public function __construct ($param_list) { $this->from=$param_list['from']; global $class_path; require_once($class_path.'/ws_rouenbs.class.php'); $this->ws = new ws_rouenbs(); } public function send_sms($telephone, $message) { global $charset; $r = FALSE; $telephone = preg_replace("/.[^0-9]/", '', $telephone); $telephone = preg_replace("/^[\+|[^0-9]]/", '', $telephone); if (strtoupper($charset) != 'UTF-8') { $message = encoding_normalize::utf8_normalize($message); $from = encoding_normalize::utf8_normalize($from); } $r = $this->ws->SendSMS($message, $telephone, $from); return $r; } } // fin de déclaration de la classe sms_pmb class allmysms { private $url = 'https://api.allmysms.com/http/9.0/'; private $login = ''; private $apikey = ''; private $tpoa = ''; public function __construct(array $param_list) { $param_list = pmb_utf8_array_encode($param_list); foreach ($param_list as $k=>$v) { if(property_exists($this, $k)) { $this->$k = $v; } } if( !preg_match("/^[a-z]{1}[a-z|0-9]{0,10}$/i", $this->tpoa)) { $this->tpoa = " "; } } public function send_sms($telephone, $message) { $telephone = preg_replace("/[^\+|0-9]/", "", $telephone); $message = encoding_normalize::utf8_normalize($message); $fields = [ 'login' => $this->login, 'apiKey' => $this->apikey, 'message' => $message, 'mobile' => $telephone, 'tpoa' => $this->tpoa, 'coding' => 2 ]; $fields_string = http_build_query($fields); $curl = new Curl(); $curl->set_option('CURLOPT_CONNECTTIMEOUT', 10); $response = $curl->post($this->url, $fields_string); $response_body = json_decode($response->body, true); if( 100 != $response_body['status'] ) { return false; } return true; } }