How to use facebook-opengraph plugin to login to yii

Hi, I am trying to use facebook graph api to login via facebook. I use the code below to show login

<?php $this->widget('ext.yii-facebook-opengraph.plugins.LoginButton', array( 'show_faces'=>true, 'registration_url'=>'http://mysite/index.php/users/facebookregister', 'oauth'=>true, // JS SDK -enable OAuth 2.0 )); ?> 

and on the redirected page I do

 <?php $userinfo = Yii::app()->facebook->getInfo() // gets the Graph info of the current user ?> but it gives me error Property "LoginButton.oauth" is not defined. i am follwing this url to http://www.yiiframework.com/extension/facebook-opengraph/ 
+4
source share
1 answer

The oauth property is not assigned inside the widget, but inside the components array of your configuration file (most likely, main.php).

 'components'=>array( 'facebook'=>array( 'class' => 'ext.yii-facebook-opengraph.SFacebook', 'appId'=>'YOUR_FACEBOOK_APP_ID', // needed for JS SDK, Social Plugins and PHP SDK 'secret'=>'YOUR_FACEBOOK_APP_SECRET', // needed for the PHP SDK //'locale'=>'en_US', // override locale setting (defaults to en_US) //'jsSdk'=>true, // don't include JS SDK //'async'=>true, // load JS SDK asynchronously //'jsCallback'=>false, // declare if you are going to be inserting any JS callbacks to the async JS SDK loader //'status'=>true, // JS SDK - check login status //'cookie'=>true, // JS SDK - enable cookies to allow the server to access the session //'oauth'=>true, // JS SDK -enable OAuth 2.0 //'xfbml'=>true, // JS SDK - parse XFBML / html5 Social Plugins //'html5'=>true, // use html5 Social Plugins instead of XFBML //'ogTags'=>array( // set default OG tags //'title'=>'MY_WEBSITE_NAME', //'description'=>'MY_WEBSITE_DESCRIPTION', //'image'=>'URL_TO_WEBSITE_LOGO', //), ), ), 
+2
source

Source: https://habr.com/ru/post/1415525/


All Articles