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ł
<?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();
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);
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)
{
'_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)
{
{
throw new Exception('Wiadomość musi mieć mniej niż 640 znaków');
}
'_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' => strlen($message), '/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
);
$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="mbox2.php5">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)
{
}
?>
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