Created
January 29, 2013 12:53
-
-
Save teslitsky/4664007 to your computer and use it in GitHub Desktop.
Correct version sms_sending SMS gateway for OpenCart with addtional phone numbers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| final class sms_sending extends SmsGate { | |
| private $url = 'http://lcab.sms-sending.ru/API/XML/send.php'; | |
| private function GetPageByUrl($headers, $post_body) { | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $this->url); // урл страницы | |
| curl_setopt($ch, CURLOPT_FAILONERROR, 1); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable | |
| curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 4s | |
| curl_setopt($ch, CURLOPT_POST, 1); // set POST method | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); // передаём post-данные | |
| $result = curl_exec($ch); // получить результат в переменную | |
| curl_close($ch); | |
| return $result; | |
| } | |
| public function send() { | |
| // Get additionals phone numbers | |
| $telephones = array_merge(array($this->to), explode(',', $this->copy)); | |
| $xml = "<?xml version='1.0' encoding='UTF-8'?> | |
| <data> | |
| <login>".$this->username."</login> | |
| <password>".$this->password."</password>"; | |
| foreach ($telephones as $telephone) { | |
| $xml .= "<to number='".$telephone."'></to>"; | |
| } | |
| $xml .= "<source>".$this->from."</source> | |
| <text>".$this->message."</text> | |
| <flash>".(int)$this->flash."</flash> | |
| </data>"; | |
| $headers[] = 'Content-Type: text/xml; charset=utf-8'; | |
| $headers[] = 'Content-Length: ' . strlen($xml); | |
| return array("answer" => $this->GetPageByUrl($headers, $xml)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment