Jump to content

How to use localAPI?


cloudtech

Recommended Posts

Hello,

 

I try to use the localAPI but get this error. Thanks for any help.

 

Fatal error: Call to undefined function localAPI() in /home/xxx/public_html/whmcs/test.php on line 9

 

 

 

<?php

 

# Set Vars

$command = 'SendEmail';

$values = array( 'messagename' => 'Test Template', 'id' => '6', );

$adminuser = 'admin';

 

# Call API

$results = localAPI($command,$values,$adminuser);

if ($results['result']!="success") echo "An Error Occurred: ".$results['result'];

 

?>

Link to comment
Share on other sites

be sure you included the following files:

 

require("dbconnect.php");
require("includes/functions.php");
require("includes/clientareafunctions.php");

 

The functions.php is required for localAPI func I guess.

 

Thanks sdemidko. I tried including those files, but got another error when I run it.

 

##Error

An Error Occurred: error

 

##The test script

 

<?php

 

require("/home/xxx/www/whmcs/dbconnect.php");

require("/home/xxx/www/whmcs/includes/functions.php");

require("/home/xxx/www/whmcs/includes/clientareafunctions.php");

 

# Set Vars

$command = 'SendEmail';

$values = array( 'messagename' => 'Test Template', 'id' => '6', );

$adminuser = 'admin';

 

# Call API

$results = localAPI($command,$values,$adminuser);

if ($results['result']!="success") echo "An Error Occurred: ".$results['result'];

 

?>

Link to comment
Share on other sites

try print out $results variable right after call

there might be an explanation

 

also be sure you using user ID in sendemail function

the template you mentioned should be in "General" section

otherwise system will expect product ID or invoice ID (Product Messages and Invoice Messages sections respectively)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated