简体   繁体   中英

How to use Facebook PHP SDK with Yii 2?

I am trying to implement Facebook SDK for PHP with Yii 2 . I am totally new to this and doing this in my config file:

'facebook' => [
            'class' => 'frontend/components/Facebook/Facebook'
        ]

The 'Facebook' folder is placed inside components folder, inside frontend. I am trying to include it like this:

use Facebook/Facebook;

But it doesn't work. How can I do it right? Any help regarding this?

In Facebook class you should have namespace:

namespace frontend\components\facebook;

And then use this like:

use frontend\components\Facebook\Facebook;

If u defined it in components in config just use it like:

\Yii::$app->facebook

it you are doing social login yii2-eauth is best for every type of social login....

check git code here

Checkout demo here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM