This code send a POST to my PHP script with the content of /who command. Then it use sockread for read the answer of my PHP script .. but my sockread get only the header. How can i get the HTML content ?
Actualy my PHP script answer 1 or 0 but i only get this :
HTTP/1.1 200 OK
Date: Mon, 01 Jul 2013 15:16:34 GMT
Server: Apache/2.2.22 (Win64) PHP/5.4.3
X-Powered-By: PHP/5.4.3
Content-Length: 1
Content-Type: text/html
alias apm {
unset %who
set %who viewer=
who #nestoyeur
}
raw 352:*:{
if ($2 == #nestoyeur) {
set %who %who $+ $3 $+ ,
}
}
raw 315:*:{
if ($2 == #nestoyeur) {
;echo -a %who
sendApm
}
}
alias sendApm {
sockclose sendApm
sockopen sendApm 127.0.0.1 80
}
on *:sockopen:sendApm:{
sockwrite -n $sockname POST /twizard/mirc/apm.php HTTP/1.1
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $len(%who)
sockwrite -n $sockname host: localhost
sockwrite -n $sockname
sockwrite $sockname %who
}
on *:sockread:sendApm:{
var %result
sockread %result
echo -a %result
}
; SEE WHAT I GET FROM " ECHO -a %RESULT " ->
;HTTP/1.1 200 OK
;Date: Mon, 01 Jul 2013 15:16:34 GMT
;Server: Apache/2.2.22 (Win64) PHP/5.4.3
;X-Powered-By: PHP/5.4.3
;Content-Length: 1
;Content-Type: text/html
the echo is failing on the empty line after the header information. For the purposes of your testing, replace line 36 with:
echo -a $iif(%result,$v1,$chr(160))
This way it doesn't end up with nothing to echo on a blank line.
If your script only returns 1 or 0, you can be confident in:
if (%result isnum) { we have our number, 1 or 0, stored in %result. do stuff! }
Also make sure your php is sending PHP_EOL (end of line) so mIRC knows the line is done, as your code, even when that echo fails, should continue!
Last but not least.... Questions should go in the forums, not snippets!