Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> "zaawansowane" zapytanie POST ze skryptu PHP, wysyłanie MMSów przez Intellisoftware nie działa
carambas
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 23.03.2009

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


Witam,

to mój pierwszy post, dzień dobry.

Mam problem z zapytaniem POST. Chcę wysłać wiadomość MMS przez bramkę intellisoftware. Pod tym (http://www.intellisoftware.co.uk/sms-gateway/http-interface/send-mms/) linkiem jest dostępny opis formatu MMSa.

Przepiszę go tu dla leniwych:



CODE
Content-Type: multipart/form-data; boundary=AaB03x

--AaB03x
Content-Disposition: form-data; name="username"
Content-Type: text/plain

YourUsername
--AaB03x
Content-Disposition: form-data; name="password"
Content-Type: text/plain

YourPassword
--AaB03x
Content-Disposition: form-data; name="to"
Content-Type: text/plain

0771012345
--AaB03x
Content-Disposition: form-data; name="from"
Content-Type: text/plain

0771054321
--AaB03x
Content-Disposition: form-data; name="type"
Content-Type: text/plain

5
--AaB03x
Content-Disposition: form-data; name="text"
Content-Type: text/plain

MMS Message Subject
--AaB03x
Content-Disposition: form-data; filename="file1.txt"
Content-Type: text/plain

... contents of file1.txt ...
--AaB03x
Content-Disposition: form-data; filename="file2.gif"
Content-Type: image/gif
Content-Transfer-Encoding: binary

...contents of file2.gif...
--AaB03x--


To jest zendowski dump mojego zapytania:
CODE
["zapytanie"] => array(1) {
["http"] => array(3) {
["method"] => string(4) "POST"
["header"] => string(52) "Content-Type: multipart/form-data; boundary=AaB03x
"
["content"] => string(5471) "--AaB03x
Content-Disposition: form-data; name="username"
Content-Type: text/plain

intelli_login
--AaB03x
Content-Disposition: form-data; name="password"
Content-Type: text/plain

intelli_password
--AaB03x
Content-Disposition: form-data; name="to"
Content-Type: text/plain

48608288403
--AaB03x
Content-Disposition: form-data; name="from"
Content-Type: text/plain

maciek
--AaB03x
Content-Disposition: form-data; name="type"
Content-Type: text/plain

5
--AaB03x
Content-Disposition: form-data; name="text"
Content-Type: text/plain

tematMMs
--AaB03x
Content-Disposition: form-data; filename="file1.txt"
Content-Type: text/plain

treasav
adfaf
aefafae
faefaefaefa


tttt

--AaB03x
Content-Disposition: form-data; filename="file2.gif"
Content-Type: image/gif
Content-Transfer-Encoding: binary

GIF89(...);
--AaB03x--"


Wyciąłem zawartość Gifa, żeby nie zaśmiecać tego tematu jeszcze bardziej.


Odpowiedź serwera to stale "request invalid". Hasło i login mam ok (jak zmienie, to krzyczy, że "login invalid"). Wydaje mi się, że zapytanie też mniej więcej ok.

Całe zapytanie wysyłam do severa w ten sposób:
CODE
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: multipart/form-data; boundary=AaB03x'."\r\n",
'content' => $content
)
);

$context = stream_context_create($opts);
$fp = fopen('http://www.intellisoftware.co.uk/smsgateway/default.aspx', 'rb', false, $context);

$result = stream_get_contents($fp);


gdzie $content to jest to, co jest w tym dumpie jedną rubrykę wyżej.

Nie wysyłałem nigdy żadnego POSTa, więc nie mam pojęcia co może być nie tak.


Za wszelkie próby pomocy z góry dziękuję!

Ten post edytował carambas 23.03.2009, 12:35:26
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
carambas
post
Post #2





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 23.03.2009

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


Dzięki za podpowiedź z plikiem. Świetny sposób testowania. Dzięki temu już wiem, że jak ustawię CURLOPT_CRLF to czyści mi zapytanie zupełnie.



Zapytanie, które wysyłam w postaci tabelki:
CODE

array(8) {
["from"] => string(5) "adfaf"
["text"] => string(5) "fafaf"
["username"] => string(6) "intelli_login"
["password"] => string(6) "intelli_haslo"
["type"] => string(1) "5"
["to"] => string(11) "48555433222"
["plik1"] => string(71) "@/var/www/eworkspace/crmsms/trunk/public//gifs/1237805374-zrobsobie.gif"
["plik2"] => string(55) "@/var/www/eworkspace/crmsms/trunk/public/gifs/tresc_tmp"
}



Wynik, który otrzymuję w pliku test.php (print_r($_POST); print_r($_FILES)(IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
CODE

Array ( [from] => adfaf [text] => fafaf [username] => intelli_login [password] => intelli_haslo [type] => 5 [to] => 48555433222 )
Array ( [plik1] => Array
( [name] => 1237805374-zrobsobie.gif [type] => image/gif [tmp_name] => /tmp/php4JB5pM [error] => 0 [size] => 4637 )
[plik2] => Array
( [name] => tresc_tmp [type] => application/octet-stream [tmp_name] => /tmp/phpfYOKLs [error] => 0 [size] => 41 )
)


Jak widać, wygląda to zupełnie poprawnie.

Odpowiedź tego cholernego intelli:
ERR:INVALID_REQUEST


Kod, którym wysyłam

CODE

$ch = curl_init('http://localhost/test.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
$ch = curl_init('http://www.intellisoftware.co.uk/smsgateway/default.aspx');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
if (curl_errno($ch)) {
echo 'Błąd #' . curl_errno($ch) . ': ' . curl_error($ch);
}


Kod wręcz zdublowany. curl_errno() nie zwraca błędów.


Wysyłał ktoś kiedyś mmsy przez intelli? SMSy działają jak trzeba.

Pzdr!
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 12.10.2025 - 22:51