Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Orange MultiBox - wysyłanie smsa, Wysyłanie smsa za pomocą bramki MultiBox Orange - dla pro
pablo86
post
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 18.07.2009

Ostrzeżenie: (0%)
-----


Witam,

Mam problem z skryptem którego zaprezentowałem poniżej. Skrypt się bez problemu uruchamia, ale nie robi tego co ma zrobić - czyli nie wysyła smsa na podany numer.

Co jest nie tak, czy może mi ktoś pomóc rozwiązać ten problem?

Paweł

  1. <?PHP
  2. header("Content-type: text/html; charset=UTF-8");
  3.  
  4. /**
  5.  * Licencja CC BY-NC-SA
  6.  * <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl" target="_blank">http://creativecommons.org/licenses/by-nc-sa/3.0/deed.pl</a>
  7.  * Klasa mbox umożliwiająca wysyłanie wiadomości SMS
  8.  * @author Kacper 'kacka' Szurek
  9.  * @mail kacperszurek (poczta w gmail.com)
  10.  * Jeżeli się przydało - napisz
  11.  * Chcesz podziękować, pomóc masz pytanie - napisz
  12.  * Skrypt przechowuje cookie w katalogu /dane/mbox.txt
  13.  *
  14.  */
  15. class mbox
  16. {
  17.    /**
  18.      * Przechowuje identyfikator połączenia curl
  19.      *
  20.      * @var $ch
  21.      */
  22.    protected $_curl;
  23.  
  24.    /**
  25.      * Ułatwienie dostępu do curl
  26.      *
  27.      * @param string $url - adres strony
  28.      * @param array $post - opcjonalnie tablica parametrów
  29.      * @return string - zwraca pobraną treść
  30.      */
  31.    public function curl($url, $post = null)
  32.    {
  33.        $this->_curl = curl_init();
  34.        
  35.        $var = array(
  36.            CURLOPT_URL => $url,
  37.            CURLOPT_COOKIEJAR => dirname(__FILE__).'/dane/mbox.txt',
  38.            CURLOPT_COOKIEFILE => dirname(__FILE__).'/dane/mbox.txt',
  39.            CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
  40.            CURLOPT_RETURNTRANSFER => true,
  41.            CURLOPT_FOLLOWLOCATION => true);
  42.                    
  43.        if ( !is_null($post) ) {
  44.            foreach ($post as $option => $value) {
  45.                $tmp .= $option. '=' .urlencode($value). '&';
  46.            }
  47.            
  48.            $var[CURLOPT_POST] = true;
  49.            $var[CURLOPT_POSTFIELDS] = $tmp;
  50.        }
  51.            
  52.        curl_setopt_array($this->_curl, $var);
  53.        
  54.        $return = curl_exec($this->_curl);
  55.    
  56.        return $return;
  57.        
  58.        curl_close($this->_curl);
  59.    }
  60.  
  61.    /**
  62.      * Funkcja logująca do orange.pl
  63.      *
  64.      * @param string $user - użytkownik
  65.      * @param string $password - hasło
  66.      */
  67.    public function login($user, $password)
  68.    {
  69.        $data = array(
  70.        '_dyncharset' => 'UTF-8',
  71.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' => 'http://www.orange.pl/portal/map/map/signin',
  72.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL=' => '',
  73.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => 'http://www.orange.pl/portal/map/map/pim',
  74.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => '',
  75.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => $user,
  76.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => '',
  77.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => $password,
  78.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => '',
  79.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' => 10,
  80.        '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' => 10,
  81.        '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' => '',
  82.        '&_DARGS' => '/gear/static/signInLoginBox.jsp'
  83.        );
  84.        
  85.        $login = $this->curl('http://www.orange.pl/portal/map/map/signin', $data);
  86.        
  87.        if (preg_match('/Podałeś błędny login lub hasło. Sprawdź je i wpisz jeszcze raz/', $login))
  88.        {
  89.            file_put_contents('/dane/mbox.txt', '');
  90.            throw new Exception('Błędne dane logowania.');
  91.        }
  92.    }
  93.    
  94.    /**
  95.      * Funkcja wysyłająca sms, sprawdza jego długość i poprawność numeru
  96.      *
  97.      * @param int $to - adres odbiorcy
  98.      * @param string $message - treść wiadomości
  99.      */
  100.    public function send($to, $message)
  101.    {
  102.        if (strlen($message) == 0 || strlen($message) > 640)
  103.        {
  104.            throw new Exception('Wiadomość musi mieć mniej niż 640 znaków');
  105.        }
  106.        
  107.        $data = array(
  108.        '_dyncharset' => 'UTF-8',
  109.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => 'sms',
  110.        '&_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => '',
  111.        'enabled' => 'false',
  112.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '/portal/map/map/message_box?mbox_view=newsms',
  113.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '',
  114.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' => '/portal/map/map/message_box?mbox_view=messageslist',
  115.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' =>'',
  116.        'smscounter' => 1,
  117.        'counter' => strlen($message),
  118.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $to,
  119.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => '',
  120.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => '',
  121.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message,
  122.        '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => '',
  123.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => 'Wyślij',
  124.        '_DARGS' => '/gear/mapmessagebox/smsform.jsp',
  125.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x' => 10,
  126.        '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y' => 10
  127.        );
  128.                
  129.        $send = $this->curl('http://www.orange.pl/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp', $data);
  130.        
  131.        if (preg_match('/Niepoprawny numer telefonu/', $send))
  132.        {
  133.            throw new Exception('Podany numer telefonu jest błędny');
  134.        }
  135.        
  136.        if (preg_match('/Wyszukaj wiadomości, których/', $send))
  137.        {
  138.            echo 'Wiadomość została prawidłowo wysłana.';
  139.        }
  140.    }
  141. }
  142. try {
  143.    if (!isset($_POST['login']))
  144.    {
  145.        echo '<form method="post" action="mbox2.php5">Login:<input type="text" name="login">
  146. Hasło:<input type="password" name="haslo">
  147. Do kogo:<input type="text" name="do">
  148. Wiadomość:<textarea name="tresc" rows="10" cols="40"></textarea><input type="submit" name="wyslij" value="Wyślij"></form>';
  149.    }
  150.    else {
  151.    $a = new mbox();
  152.    $a->login($_POST['login'], $_POST['haslo']);
  153.    $a->send($_POST['do'], $_POST['tresc']);
  154.    }
  155. } catch (Exception $e)
  156. {
  157.    echo $e->getMessage();
  158. }
  159.  
  160. ?>


Bardzo proszę o pomoc, na prawdę zależy mi na tym skrypcie..

Czekam na jakąś podpowiedź

Proszę o pomoc

Ten post edytował pablo86 20.07.2009, 14:43:34
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 18:33