API tutorial
API Tutorial
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.
What means in
$succ = $con->PHPSconnect("SERVER ADRESSS","PASSWORD","PORT");
"Password"? Server Adress is the Server IP , isn't it?
You have by the class $con = new PHPSend(); one s too little
sorry for my bad English
can somebody tell me what im doing wrong? :
<?php include_once("PHPSend.php"); ?> <?php $con = new PHPSend(); $succ = $con->PHPSconnect("serverip","mypass","11223"); $con->PHPScommand("say Server says Hello!"); $con->PHPScommand("say Server sets time to Day!"); $succ = $con->PHPSdisconnect(); ?>
i get this error: Fatal error: Class 'PHPSend' not found in /home/u523880420/public_html/cpanel/index.php on line 4
help me please
Hey guys... I got the same error like jeffreykcorporation. Please help me.
@Th3G4m3r
@jeffreykcorporation
That's an easy solve. I guess the plugin author made a mistake. Change the "$con = new PHPSend();" line to "$con = new PHPSsend();" and you'll be fine.
However. I got a problem also. Problem is following:
Warning: socket_read(): unable to read from socket [10054]: An existing connection was forcibly closed by the remote host. in C:\xampp\htdocs\Bukkit\PHPSend.php on line 21
And $succ returns 5. I have no idea how to solve this.