Firstly, in the beggining of the code include PHPSend.php
<?php include_once("PHPSend.php"); ...
Then you need to create PHPSend connector and connect to server. We store the results in $succ.
... $con = new PHPSend(); $succ = $con->PHPSconnect("SERVER ADRESSS","PASSWORD","PORT"); ...
- $succ is 0 when everything is OK.
- $succ is 1 when PHPsend couldn't connect to server
- $succ is 2 when Password is incorrect. You can check the results, but I'm going to skip this step now.
We are connected, so we can execute commands:
... $con->PHPScommand("say Server says Hello!"); $con->PHPScommand("say Server sets time to Day!"); $con->PHPScommand("time day"); ...
PHPScommand return 0 when command was executed, 1 otherwise (THIS DOESN'T INCLUDE COMMAND ERROR, LIKE "UNKNOWN COMMAND"), but It's rarely used. After executing commands, we have to disconnect from server.
... $succ = $con->PHPSdisconnect(); ...
- $succ is 0 when disconnected succesfully
- $succ is 1 when disconnecting failed (server not responds) You can handle those errors, if needed.
We are done. Next client can connect now.
- 1 comment