我一直在使用PHP Rest SDK,已经能够登录/注销并收集所有可能的用户信息,但是如果我将范围更改为包括“地址”,或者只是将数组保留为空,则默认为sdks默认值,我收到以下错误:

致命错误:在/ Users // Sites // framework中找不到类'PPOpenIdAddress'。**。dev / private / modules / paypal / vendor / paypal / sdk-core-php / lib / PayPal / Common / PPModel.php第51行

如果我从范围中删除地址字段,然后一切运行顺利。

添加地址之前的范围:

public function createLogin(){
    try {
        $_array = array('openid', 'email', 'profile', 'phone', 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout');
        return PPOpenIdSession::getAuthorizationUrl(PAYPALURL, $_array, $this->_clientid,  $this->getApiContext());
    } catch (PayPal\Exception\PPConnectionException $_exception) {
        $this->_errormsg = $_exception->getMessage();
        $this->_errordata = $_exception->getData();

        return false;
    }
}


添加地址后的范围:

public function createLogin(){
    try {
        $_array = array('openid', 'email', 'profile', 'address', 'phone', 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout');
        return PPOpenIdSession::getAuthorizationUrl(PAYPALURL, $_array, $this->_clientid,  $this->getApiContext());
    } catch (PayPal\Exception\PPConnectionException $_exception) {
        $this->_errormsg = $_exception->getMessage();
        $this->_errordata = $_exception->getData();

        return false;
    }
}


不知道出了什么问题

最佳答案

找到了解决方案。似乎这里实现的反射使用PHPDOC来检索类名。在PPOpenIdUserinfo.php中找到吸气方法getAddress()就足够了。我将@return PPOpenIdAddress更改为@return PayPal\Auth\Openid\PPOpenIdAddress(我基本上在类旁边添加了名称空间)。我希望PayPal API的一些专家可以证实这一点。

10-06 12:42
查看更多