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--
--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--"
["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);
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ę!