Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2017
    Posts
    22
    Points
    474
    Level
    7

    Question Regarding .tpl file in plugin

    Hi,
    How can I perform API call (written in php) inside .tpl file ? I have following php code inside .tpl file & If I'm trying to run below code its showing this error 'A system error has occurred. Please try your request again in a few minutes. '.
    Its because of SoapClient call. I don't know the proper way to use SoapClient inside the .tpl file, so please suggest me one good example.

    {php}
    class Test
    {
    public function authenticate($api_controller, $action, $input=null)
    {
    $key = array( ’email’ => ’siteworx@siteworx.com’,
    ’password’ => ’siteworxpass’,
    ’domain’ => ’example.com’ );
    $client = new SoapClient( 'https://%%SERVERNAME%%:2443/soap?wsdl' );
    if (!$input) {
    $response = $client->route($key, $api_controller, $action);
    }
    else {
    $response = $client->route($key, $api_controller, $action, $input);
    }
    return $response;
    }


    public function getSize()
    {
    $action = 'listAccountDetails';
    $api_controller = '/siteworx/overview';
    $response = $this->authenticate($api_controller, $action);
    return $response['payload']['remaining_diskspace'];
    <!-- It will return disk size ex 500MB -->
    }
    }
    $control_panel = new Test();
    print_r($control_panel->getSize());
    {/php}




    Thank you,
    kiran

  2. #2
    Join Date
    Apr 2012
    Posts
    2,179
    Points
    24,154
    Level
    67
    Hi kiran

    You may want to hold off until the smarty has been corrected fully.

    If you have updated to IW smarty 3.1, there is something giving an error but all appears to work

    Also, smarty 3.1 has depreciated some php code

    Many thanks

    John

  3. The Following User Says Thank You to d2d4j For This Useful Post:


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •