![]() |
![]() |
![]() ![]()
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ł
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 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 48 Pomógł: 3 Dołączył: 7.12.2007 Ostrzeżenie: (0%) ![]() ![]() |
A więc do czego doszedłem po chwili główkowania:
Twój skrypt loguje się do serwisu poprawnie, kiedy jednak próbuje wysłać smsa, po wywaleniu efektu otrzymałem "Przepraszamy. Podana strona nie istnieje", czyli 404 orange. Może to być niepoprawny adres, może być zabezpieczenie forwardujące do strony 404 kiedy coś mu się nie zgadza. Pierwsza moja sugestia: Ustaw referera w cURLu. Poza tym zawartość POST jaką wysyła cURL, oraz zawartość POST jaką wysyła prawdziwy MultiBox nieco się różni: To jest POST Twojego skryptu: Kod _dyncharset = UTF-8 /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_type = sms _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_type = enabled = false /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_errorURL = /portal/map/map/message_box?mbox_view=newsms _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_errorURL = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_successURL = /portal/map/map/message_box?mbox_view=messageslist _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_successURL = smscounter = 1 counter = 3 /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_to = 666 _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_to = _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_body = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_body = asd _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create = Wy�lij _DARGS = /gear/mapmessagebox/smsform.jsp /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create_x = 10 /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create_y = 10 A to jest POST MultiBoxa: Kod _dyncharset = UTF-8 /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_type = sms _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_type = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_token = 2xV1WzOU7yoO4hU _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_token = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_to = 666 _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_to = _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_body = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_body = od mikz: /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create_x = 39 /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create_y = 10 _D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create = /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_create = true _DARGS = /gear/guiextensions/multibox_sms.jsp.multibox-SMSForm Przede wszystkim zwróć uwagę na pole /amg/ptk/map/messagebox/formhandlers/MessageFormHandler_token w którym znajduje się być może jakiś cholerny ciąg weryfikujący czy cokolwiek w tym stylu. Tyle na dzisiaj, nie mam już siły nad tym siedzieć bo całą noc gryzłem się nad różnymi phpowymi rzeczami. Jutro spróbuję podłubać w tym Twoim skrypcie bo chciałbym go wykorzystać a i mam nadzieję że Tobie w czymś pomogłem. Aaaa, byłbym zapomniał. Sprawę analizy formularzy zdecydowanie ułatwia wyłączenie javascripta. Multibox nieźle sobie radzi na pure html a formy nie są wtedy submitowane przez ajax. Przepraszam za posta pod postem, ale za długie było żeby to w jednym upchnąć. Oto działająca wersja Twojego skryptu: Kod <?php header("Content-type: text/html; charset=UTF-8"); /** * Licencja CC BY-NC-SA * <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> * Klasa mbox umożliwiająca wysyłanie wiadomości SMS * @author Kacper 'kacka' Szurek * @mail kacperszurek (poczta w gmail.com) * Jeżeli się przydało - napisz * Chcesz podziękować, pomóc masz pytanie - napisz * Skrypt przechowuje cookie w katalogu /dane/mbox.txt * */ class mbox { /** * Przechowuje identyfikator połączenia curl * * @var $ch */ protected $_curl; /** * Ułatwienie dostępu do curl * * @param string $url - adres strony * @param array $post - opcjonalnie tablica parametrów * @return string - zwraca pobraną treść */ public function curl($url, $post = null) { $this->_curl = curl_init(); $var = array( CURLOPT_URL => $url, CURLOPT_COOKIEJAR => dirname(__FILE__).'/dane/mbox.txt', CURLOPT_COOKIEFILE => dirname(__FILE__).'/dane/mbox.txt', CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6', CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true); if ( !is_null($post) ) { foreach ($post as $option => $value) { $tmp .= $option. '=' .urlencode($value). '&'; } $var[CURLOPT_POST] = true; $var[CURLOPT_POSTFIELDS] = $tmp; } curl_setopt_array($this->_curl, $var); $return = curl_exec($this->_curl); return $return; curl_close($this->_curl); } /** * Funkcja logująca do orange.pl * * @param string $user - użytkownik * @param string $password - hasło */ public function login($user, $password) { $data = array( '_dyncharset' => 'UTF-8', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' => 'http://www.orange.pl/portal/map/map/signin', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL=' => '', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => 'http://www.orange.pl/portal/map/map/pim', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' => '', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => $user, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' => '', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => $password, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' => '', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' => 10, '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' => 10, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' => '', '&_DARGS' => '/gear/static/signInLoginBox.jsp' ); $login = $this->curl('http://www.orange.pl/portal/map/map/signin', $data); if (preg_match('/Podałeś błędny login lub hasło. Sprawdź je i wpisz jeszcze raz/', $login)) { file_put_contents('/dane/mbox.txt', ''); throw new Exception('Błędne dane logowania.'); } } /** * Funkcja wysyłająca sms, sprawdza jego długość i poprawność numeru * * @param int $to - adres odbiorcy * @param string $message - treść wiadomości */ public function send($to, $message) { if (strlen($message) == 0 || strlen($message) > 640) { throw new Exception('Wiadomość musi mieć mniej niż 640 znaków'); } //Dodał Mikz $tokenStack = $this->curl('http://www.orange.pl/portal/map/map/message_box?mbox_view=newsms'); $position0 = strpos($tokenStack, '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.token'); $position = $position0-37; $token = substr($tokenStack, $position, 15); ///////////// $data = array( '_dyncharset' => 'UTF-8', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => 'sms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' => '', 'enabled' => 'true', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.token' => $token, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.token' => '', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '/portal/map/map/message_box?mbox_view=newsms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL' => '', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' => '/portal/map/map/message_box?mbox_view=messageslist', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL' =>'', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => $to, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to' => '', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => '', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body' => $message, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => '', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create' => 'Wyślij', '_DARGS' => '/gear/mapmessagebox/smsform.jsp', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x' => 10, '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y' => 10 ); curl_setopt ($this->_curl, CURLOPT_REFERER, 'http://www.orange.pl/portal/map/map/message_box?mbox_view=newsms'); $send = $this->curl('http://www.orange.pl/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp', $data); if (preg_match('/Niepoprawny numer telefonu/', $send)) { throw new Exception('Podany numer telefonu jest błędny'); } if (preg_match('/Wyszukaj wiadomości, których/', $send)) { echo 'Wiadomość została prawidłowo wysłana.'; } } } try { if (!isset($_POST['login'])) { echo '<form method="post" action="test.php">Login:<input type="text" name="login"> Hasło:<input type="password" name="haslo"> Do kogo:<input type="text" name="do"> Wiadomość:<textarea name="tresc" rows="10" cols="40"></textarea><input type="submit" name="wyslij" value="Wyślij"></form>'; } else { $a = new mbox(); $a->login($_POST['login'], $_POST['haslo']); $a->send($_POST['do'], $_POST['tresc']); } } catch (Exception $e) { echo $e->getMessage(); } ?> Jeszcze Ci jakieś notice'y wywala po submicie, ale generalnie smsy wysyła. Pozdrawiam :-). Będę wdzięczny jeśli wyślesz mi całość skryptu przez PW jak go skończysz :-). Pozdrawiam Ten post edytował Mikz 1.08.2009, 04:54:16 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 14.10.2025 - 17:33 |