首页 > 解决方案 > php 函数给出一个循环 - hostfact API

问题描述

我正在使用 hostfact https://www.hostfact.nl进行计费。现在我想扩展代码并获得一个在 hooks.php 中执行 internalAPI 的循环。我试图在文档https://www.hostfact.nl/developer/api/中找到答案,但没有成功。

// When a client is edited, the bankParameters are checked and validated.
// That is only an example
function action_debtor_is_edited($parameters){
     
    $params     = array(
                        'DebtorCode' => $parameters['DebtorCode']
                        );
    $hostfactResult = internalAPI('debtor', 'show', $params);
    
    $bankParams = array(
                        'Identifier'    => '2',
                        'AccountNumber' => 'AT6734080000000000',
                        'AccountBank'   => 'test bank',
                        'AccountCity'   => 'city',
                        'AccountBIC'    => 'RLNODASD'
                        );
                
    $bankResult = internalAPI('debtor', 'edit', $bankParams); 
}

我已经询问了支持并得到了以下答案:

一种选择是跟踪情况。例如,使用静态或全局变量。当您从 webhook 调用(内部)API 调用时,首先标记该变量,因此在新调用的 webhook 中,您知道不需要再次执行 webhook(至少不是导致循环的部分)。在原始调用中,收到结果后,可以再次取消设置该标志。

我的问题是,我是 PHP 新手,不明白应该怎么做才能避免循环。$bankParams 变量是故意硬编码的。你能帮我吗?

标签: phploops

解决方案


推荐阅读