Jump to content

Using PHP SDK


Guest Chudy

Recommended Posts

Posted

I tried to use PHP SDK and just call a simple function that prints something in console.

My PHP code looks like this:

<? 
  
include( "mta_sdk.php" ); 
  
$mtaServer = new mta("ip", 22005, "test", "test"); //i wasn;t sure with this but i added to accounts.xml and acl.xml user 'test' 
  
$resource = $mtaServer->getResource ( "lh" ); // the resource i'm using 
$returns[] = $resource->call ( "smth" );// the lua function 
?> 

But it does not work, it shows up this:

Fatal error: Uncaught exception 'Exception' with message 'Not Found' in /var/www/web1/html/mta_sdk.php:203 Stack trace: #0 /var/www/web1/html/mta_sdk.php(79): mta->do_post_request('my_ip', 22005, '/lh/call/smth', '') #1 /var/www/web1/html/mta_sdk.php(257): mta->callFunction('lh', 'smth', Array) #2 /var/www/web1/html/index123.php(: Resource->call('smth') #3 {main} thrown in /var/www/web1/html/mta_sdk.php on line 203 

@edit

I think the problem is with the username, there is something about http username and password in mta_sdk.php but how can i make that username?

By the way, I don't know if this has to do with it, but only resource I am running is the one i made and 'scoreboard'

Also, is there any way to disable the http authentication?

Posted

Is 22005 your server's http port? Thats the port you should be specifying...

Posted

Ofcourse it is, because when I use another port in my PHP script it says ' Uncaught exception 'Exception' with message 'Could not connect to IP:PORT'

Posted
Also, is there any way to disable the http authentication?

The best way to do this is to give Default acl access to HTTP.

In acl.xml:

<right name="general.http" access="true" /> 

Posted

'Not found' means the function you are trying to call does not exist, right? So you have to export it first.

In meta.xml:

<export function="functionName" http="true" /> 

Posted

If you need any help with the PHP SDK or anything relating to the web interface, come and bug me on IRC.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...