前台登录直接返回异常Facebook\Exceptions\FacebookSDKException

问题咨询 · sjg20010414 · 于 8天前 发布 · 31 次阅读

我直接按生产方式(步骤参照安装文档)在ubuntu18.04 server上部署了fecmall,后台输入数据正常,前台浏览其余目前正常,但点击登录,直接返回以下异常

有谁遇到类似问题或者知道如何修改、跟踪调试的,敬请告知,不胜感激

地址栏 http://ipAddress//customer/account/login 异常返回信息如下:(我是把 appfront/web/index.php 从生产模式改成 DEBUG=true, dev 的)

Facebook\Exceptions\FacebookSDKException Required "app_id" key not supplied in config and could not find fallback environment variable "FACEBOOK_APP_ID"

  1. in /var/www/xyfecmall/xymall/vendor/facebook/graph-sdk/src/Facebook/Facebook.phpat line 139

    130131132133134135136137138139140141142143144145146147148            'default_graph_version' => static::DEFAULT_GRAPH_VERSION,
             'enable_beta_mode' => false,
             'http_client_handler' => null,
             'persistent_data_handler' => null,
             'pseudo_random_string_generator' => null,
             'url_detection_handler' => null,
         ], $config);
     
         if (!$config['app_id']) {
             throw new FacebookSDKException('Required "app_id" key not supplied in config and could not find fallback environment variable "' . static::APP_ID_ENV_NAME . '"');
         }
         if (!$config['app_secret']) {
             throw new FacebookSDKException('Required "app_secret" key not supplied in config and could not find fallback environment variable "' . static::APP_SECRET_ENV_NAME . '"');
         }
     
         $this->app = new FacebookApp($config['app_id'], $config['app_secret']);
         $this->client = new FacebookClient(
             HttpClientsFactory::createHttpClient($config['http_client_handler']),
             $config['enable_beta_mode']
    
  2. in /var/www/xyfecmall/xymall/vendor/fancyecommerce/fecshop/services/customer/Facebook.php at line 45–
    Facebook\Facebook::__construct(['app_id' => '', 'app_secret' => '', 'default_graph_version' => 'v2.10', 'enable_beta_mode' => false, ...])
    39404142434445464748495051        $thirdLogin  = Yii::$service->store->thirdLogin;
         $this->facebook_app_id     = isset($thirdLogin['facebook']['facebook_app_id']) ? $thirdLogin['facebook']['facebook_app_id'] : '';
         $this->facebook_app_secret = isset($thirdLogin['facebook']['facebook_app_secret']) ? $thirdLogin['facebook']['facebook_app_secret'] : '';
         $fb = new \Facebook\Facebook([
             'app_id' => $this->facebook_app_id,
             'app_secret' => $this->facebook_app_secret,
             'default_graph_version' => 'v2.10',
         ]);
         $helper = $fb->getRedirectLoginHelper();
         $permissions = ['email']; // Optional permissions
         $loginUrl = $helper->getLoginUrl($redirectUrl, $permissions);
         return $loginUrl;
     }
    
  3. in /var/www/xyfecmall/xymall/vendor/fancyecommerce/fecshop/app/appfront/modules/Customer/block/account/Login.php at line 34–

    fecshop\services\customer\Facebook::getLoginUrl('customer/facebook/loginv')
    28293031323334353637383940        $email = isset($param['email']) ? $param['email'] : '';
         $this->breadcrumbs(Yii::$service->page->translate->__('Login'));
         return [
             'loginPageCaptcha' => $loginPageCaptcha,
             'email' => $email,
             'googleLoginUrl' => Yii::$service->customer->google->getLoginUrl('customer/google/loginv'),
             'facebookLoginUrl' => Yii::$service->customer->facebook->getLoginUrl('customer/facebook/loginv'),
         ];
     }
     
     // 面包屑导航
     protected function breadcrumbs($name)
     {
    
  4. in /var/www/xyfecmall/xymall/vendor/fancyecommerce/fecshop/app/appfront/modules/Customer/controllers/AccountController.php at line 62–

    fecshop\app\appfront\modules\Customer\block\account\Login::getLastData(null)
    56575859606162636465666768        if (!empty($param) && is_array($param)) {
             $this->getBlock()->login($param);
             if (!Yii::$app->user->isGuest) {
                 return Yii::$service->customer->loginSuccessRedirect('customer/account');
             }
         }
         $data = $this->getBlock()->getLastData($param);
     
         return $this->render($this->action->id, $data);
     }
     
     /**
      * 注册.
    
  5. action Login
    fecshop\app\appfront\modules\Customer\controllers\AccountController::actionLogin() 
    
  6. in /var/www/xyfecmall/xymall/vendor/yiisoft/yii2/base/InlineAction.php at line 57–
    call_user_func_array([fecshop\app\appfront\modules\Customer\controllers\AccountController, 'actionLogin'], [])
    
  7. in /var/www/xyfecmall/xymall/vendor/yiisoft/yii2/base/Controller.php at line 157–
    yii\base\InlineAction::runWithParams([])
    
  8. in /var/www/xyfecmall/xymall/vendor/yiisoft/yii2/base/Module.php at line 528–
    yii\base\Controller::runAction('login', [])
    
  9. in /var/www/xyfecmall/xymall/vendor/yiisoft/yii2/web/Application.php at line 103–
    yii\base\Module::runAction('customer/account/login', [])
    
  10. in /var/www/xyfecmall/xymall/vendor/yiisoft/yii2/base/Application.php at line 386–
    yii\web\Application::handleRequest(fecshop\yii\web\Request)
    
  11. in /var/www/xyfecmall/xymall/appfront/web/index.php at line 66–
    yii\base\Application::run()
    new fecshop\services\Application($config);
    $application = new yii\web\Application($config);
    $application->run();
    $_COOKIE = [
    'PHPSESSID' => 'djj8k2jpbd5hbvimc52k1109ri',
    ];
    $_SESSION = [
    '__flash' => [],
    'currency_current' => 'CNY',
    ];
    
共收到 2 条回复
sjg20010414#17天前 0 个赞

我来自问自答一下:

我在后台对 appfront 的 store 配置时,没有设置 facebook app id 和 secret,当登录时,转向 customer/account/login,到 AccountController.php的 62 行 $data = $this->getBlock()->getLastData($param); 失败,跟踪到 block/account/login 的 getLastData 的返回句 失败

return [
            'loginPageCaptcha' => $loginPageCaptcha,
            'email' => $email,
            'googleLoginUrl' => Yii::$service->customer->google->getLoginUrl('customer/google/loginv'),
            'facebookLoginUrl' => Yii::$service->customer->facebook->getLoginUrl('customer/facebook/loginv'),
        ];

实际 Yii::$service->customer->facebook->getLoginUrl('customer/facebook/loginv') 异常,跟踪到 services/customer/FaceBook.php 的以下语句

$fb = new \Facebook\Facebook([
            'app_id' => $this->facebook_app_id,
            'app_secret' => $this->facebook_app_secret,
            'default_graph_version' => 'v2.10',
        ]);

facebook_app_id, facebook_app_secret 都是空的,还试图创建对象,从而 FaceBook 类在 138-142行抛出异常

修改意见:facebook_app_id, facebook_app_secret 都是空的不要创建对象,前面应加以判断 绕过办法:后台给 appfront 的Store 随便设置一个 facebook appid appsecret

Fecmall#27天前 0 个赞

1.帖子内容请整理一下,太乱

2.bug已经处理,参看:https://github.com/fecshop/yii2_fecshop/commit/278635f9ab23ed68c326ba8a80ee6c18a04d580d

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics