【发布时间】:2016-04-26 22:51:09
【问题描述】:
我正在尝试在我的预订系统中实施 Authorize.net 自动定期计费 (ARB) API,但在尝试自动加载课程时遇到了错误。这是我的自定义自动加载功能不起作用:
function aim2_autoload($class) {
if (file_exists('../AIM-2.0/vendor/'.$class.'.php')) {
require '../AIM-2.0/vendor/'.$class.'.php';
}
if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/'.$class.'.php')) {
require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/'.$class.'.php';
}
if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/shared/'.$class.'.php')) {
require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/shared/'.$class.'.php';
}
if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/'.$class.'.php')) {
require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/'.$class.'.php';
}
if (file_exists('../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/'.$class.'.php')) {
require '../AIM-2.0/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/'.$class.'.php';
}
}
spl_autoload_register('aim2_autoload');
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
但是,我收到错误消息:
Fatal error: Class 'net\authorize\api\contract\v1\MerchantAuthenticationType' not found in /home/user/example.com/cart/reservation/ajax-submit.php on line 122.
我尝试寻找在 autoload 函数中同时使用 use 语句的替代方法,但一无所获。任何帮助将不胜感激。
【问题讨论】:
标签: php api autoload authorize.net spl-autoload-register