更新了 PayPal 但为什么“致命错误:找不到类 'PayPal\REST\ApiContext'"? [英] Updated PayPal but why "Fatal error: Class 'PayPal\REST\ApiContext' not found"?

查看:77
本文介绍了更新了 PayPal 但为什么“致命错误:找不到类 'PayPal\REST\ApiContext'"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的 PHP 应用程序从本地主机移动到在线服务器,但收到一个错误:致命错误:找不到类 'PayPal\REST\ApiContext'.我已经厌倦了按照其他帖子中的建议更新 PayPal SDK.ApiContext 仍然出现此错误.我的启动文件代码如下.我已经实施了其他帖子中描述的修复程序,但无济于事.任何帮助,将不胜感激.

I am moving my PHP application from localhost to online server and I receive an error: Fatal error: Class 'PayPal\REST\ApiContext' not found. I have tired to update the PayPal SDK as suggested in other posts. Still getting this error with the ApiContext. My code for the start file is below. I have implemented the fix described in other posts to no avail. Any help would be appreciated.

<?php

use PayPal\REST\ApiContext;
use PayPal\Auth\OAuthTokenCredential;

session_start();
include('connect.php');

//determine if user signed in

if (isset($_SESSION['uid'])){
$userPAYPAL = $_SESSION['uid'];
} else {
header("Location:../../register.php");
}


require __DIR__ . '/../vendor/autoload.php';

//create new PayPal API context (ERROR OCCURS HERE)
$api = new ApiContext(
new OAuthTokenCredential(

'AZp2HH9aWL2QxjVZRO51N33ZLqweiO5x_GPIyUMWgqLYhe0yxfQSPhJaUkCyqx8OHT',

'EGpHg8K23idpNF895v6Zm4rybajrvAoED6T0As0NUk4q2fhJ7oDv82z1PKTECiHfkl'
)
);

$api->setConfig([
'mode' => 'sandbox',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => false,
'log.FileName' => '',
'log.LogLevel' => 'FINE',
'validation.level' => 'log'

]);

推荐答案

我相信您会看到由于区分大小写而造成的差异.您在代码的顶部:

I do believe you are seeing the discrepancy due to case sensitivity. You have at the top of your code:

use PayPal\REST\ApiContext;

当它在他们的代码中用 Rest 定义时:

When it is defined in their code with a Rest like:

use PayPal\Rest\ApiContext;

<小时>

顺便说一句,我喜欢使用 paypal rest sdk 的方式是,当我调用它们的任何对象或方法时,我只使用完整的命名空间......就像 $apiContext = new PayPal\Rest\ApiContext( .. );$addr = new PayPal\Api\Address(); 等这样我就不会冲突我的自己的代码与use.


On a side note, the way I like to use the paypal rest sdk, is when I'm calling any of their objects or methods, I just use the full namespace... like $apiContext = new PayPal\Rest\ApiContext( .. ); and $addr = new PayPal\Api\Address(); etc. That way I don't clash my own code with the use.

这篇关于更新了 PayPal 但为什么“致命错误:找不到类 'PayPal\REST\ApiContext'"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆