Vuejs Facebook Login using PHP – vue facebook-login

In this Post We Will Explain About is Vuejs Facebook Login using PHP – vue facebook-login With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Login with facebook using vuejs- Demo and DownloadExample

In this post we will show you Best way to implement Simple Facebook Connect Vuejs Example Code Example, hear for Login System with Facebook with Vuejs and PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  AngularJS Nested ng-if parent scope Examples

vue-authenticate is simple and setps easily configurable solution for Vue.js web-apps that all the provides local system and get some information login/registration as well as ther are Social login using Like as a Facebook authenticate, Google authenticate and Twitter authenticate OAuth providers.

index.html


  
    
    <title>vue-simple-facebook-login</title>
  
  
  <h1></h1>
    <div id="liveApp"></div>
  

template

<h1></h1>

  <div id="liveApp">
    <div class="">
      <button class="btn btn-primary">FB Logout</button>
      <button class="btn btn-primary">FB Login</button>

      <hr /><hr /><hr />

      <div class="">
        <img src="./assets/logo.png">
        
      </div>
    </div>

    <div class="">
      
        <img src="/static/shiba_walk.gif" alt="" width="500px" />
      
    </div>
  </div>

main.js

import Vue from 'vue'
import App from './App'

(function (d, s, id) {
  var myjs
  var firstjs = d.getElementsByTagName(s)[0]
  if (d.getElementById(id)) return
  myjs = d.createElement(s); myjs.id = id
  myjs.src = '//connect.facebook.net/en_US/sdk.js'
  firstjs.parentNode.insertBefore(myjs, firstjs)
}(document, 'script', 'facebook-jssdk'))

new Vue({
  el: '#liveApp',
  template: '',
  components: { App }
})

App.vue

import first-app from './components/first-app'
export default {
  name: 'liveApp',
  components: {
    first-app
  },
  data () {
    return {
      profile: {},
      phase_data: false,
      get_auth_data: false
    }
  },
  methods: {
    get_myprofile () {
      let vue_mount = this
      FB.api('/me', function (result_data) {
        alert(result_data)
        vue_mount.$set(vue_mount, 'profile', result_data)
      })
    },
    login () {
      let vue_mount = this
      FB.login(function (result_data) {
        vue_mount.statusChangeCallback(result_data)
      }, {scope: 'publish_actions'})
    },
    logout () {
      let vue_mount = this
      FB.logout(function (result_data) {
        vue_mount.statusChangeCallback(result_data)
      })
    },
    statusChangeCallback (result_data) {
      let vue_mount = this
      vue_mount.phase_data = true
      alert('statusChangeCallback')
      alert(result_data)
      if (result_data.status === 'connected') {
        vue_mount.get_auth_data = true
        vue_mount.get_myprofile()
      } else if (result_data.status === 'not_authorized') {
        vue_mount.get_auth_data = false
      } else {
        vue_mount.get_auth_data = false
      }
    }
  },
  mounted () {
    let vue_mount = this
    window.fbAsyncInit = () => {
      FB.init({
        appId: '1958478585556856',
        cookie: true,
        xfbml: true,
        version: 'v2.8'
      })
      FB.getLoginStatus(function (result_data) {
        vue_mount.statusChangeCallback(result_data)
      })
    }
  }
}

Style.css

.box {
  background-color: #3D2D3D;
  margin-bottom: 30px;
  padding: 30px;
  border-radius: 6px;
}
html, body {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #eee;
  background-color: #ddd;
  text-align: center;
  padding: 20px;
}


Example

READ :  Multiple Image Upload in php with Database

I hope you have Got What is vuejs facebook login – Login with Facebook using Vuejs And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.