lzakrzewski/facebook-authentication-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lzakrzewski/facebook-authentication-bundle

Composer 安装命令:

composer require lzakrzewski/facebook-authentication-bundle

包简介

This bundle helps you to add "Login with facebook" feature to your app

README 文档

README

Build Status Latest Stable Version Total Downloads

This bundle provides Facebook authentication for your Symfony2 app using the FOSUserBundle. Target: Keep it minimalistic and use existing components from Symfony2 and FOSUserBundle.

Features

  • Enable login with facebook feature to your app,
  • Add user created from facebook data to your app.

Requirements

    "require": {
        "php": ">=5.4",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "lzakrzewski/facebook-authentication-adapter": "~1.0"
    }

Supported Facebook API version

  • v2.5

Installation

Step 1: Integrate FOSUserBundle with your app

Read the Documentation for master.

Step 2: Require the FacebookAuthenticationBundle with composer

composer require lzakrzewski/facebook-authentication-bundle "~1.0"

Step 3: Enable the FacebookAuthenticationBundle

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Lzakrzewski\FacebookAuthenticationBundle\LzakrzewskiFacebookAuthenticationBundle(),
        // ...
    );
}

Step 4: Implement your User class with FacebookUser

<?php
// src/AppBundle/Entity/User.php

namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Lzakrzewski\FacebookAuthenticationBundle\Model\FacebookUser;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User extends BaseUser implements FacebookUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="bigint", nullable=true)
     */
    private $facebookId;

    /** {@inheritdoc} */
    public function getFacebookId()
    {
        return $this->facebookId;
    }

    /** {@inheritdoc} */
    public function setFacebookId($facebookId)
    {
        $this->facebookId = $facebookId;
    }
}

Notice field for store FacebookId should be named facebookId or Annotation FacebookId should be used: FacebookId Annotation.

Step 5: Configure the config.yml

Minimal configuration:
lzakrzewski_facebook_authentication:
    app_id: 1234
    app_secret: secret

Parameters: app_id and secret are needed to get access token: Access Tokens.

Example of full configuration:
lzakrzewski_facebook_authentication:
    app_id: 1234
    app_secret: secret
    scope: ["public_profile", "email", "user_birthday"]
    fields: ["name", "email", "birthday"]

Parameters:

  • scope An array of permissions: Permissions with Facebook Login,
  • fields By default, not all the fields in a node or edge are returned when you make a query. You can choose the fields (or edges) you want returned with the "fields" query parameter. Choosing Fields.

Notice

  • scope Should contain public_profile, email or more,
  • fields Should contain name, email or more.

Step 6: Confgure your routing.yml

facebook_login_path:
    pattern: /facebook/login

Step 7: Enable facebook_listener in your security.yml

# app/config/security.yml
security:
    # ...
    
    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4

            logout:       true
            anonymous:    true
            # Enable facebook_listener  
            lzakrzewski_facebook: true
            
    # ...

Step 8: Update your database schema

php app/console doctrine:schema:update --force

Step 9: Setup your facebook app

Documentation

Now when route /facebook/login will be requested then procedure of code exchange will be process Code exchange.

Further documentation

统计信息

  • 总下载量: 75
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固