php - yii中如何使用facebook-opengraph插件登录

标签 php facebook yii

您好,我正在尝试使用 facebook graph api 通过 facebook 登录。我正在使用下面的代码来显示登录

<?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
)); ?>

在我正在做的重定向页面中

<?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/

最佳答案

oauth 属性不是在小部件中分配的,而是在配置文件(很可能是 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',
    //),
  ),
),

关于php - yii中如何使用facebook-opengraph插件登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10846790/

相关文章:

php - Yiibooster TbButton 网址链接无效

php - 将 Yii ActiveRecord 模型插入 mysql 表时出错

php - 使用 Yii CActiveDataProvider 时如何将 2 个模型与关系连接起来

php - 用于提交按钮的 HTML 不会将数据插入数据库并一起重定向到 URL

php - 使用 while 循环回显 PHP 数组

php - 如何使用 SplFileObject 获取行数?

php - Facebook 应用程序 : Secure Canvas URL

javascript - Facebook FB.ui,Feed 消息对象不工作

android - 即使成功登录到 Facebook,session.isOpened() 也会返回 false

php - Yii:自定义 CRUD/管理 URL