Laravel
  • Introduction
  • 常用語法
  • 結合Vue.js從無到有架設一個網站
  • 透過CMD新增File
  • Schedule
  • Annotation
  • Super Variable
  • API的設定
  • Create 新專案
  • Raw Expressions
  • Import - Export
  • JWT 外加 登入功能
  • Carbon
  • Storage 保存文件
  • Require_once
  • 設定apache將laravel專案run起來
  • 有關leftjoin的用法
  • Advanced Join Clauses
  • Call API方式
  • 產生新的APP_KEY
  • 程序優化技巧
  • composer update VS 手動丟檔
  • 全域變數被使用過
  • FB的SDK
Powered by GitBook
On this page
  • 安裝
  • 設定
  • 使用

Was this helpful?

FB的SDK

laravel 導入 FB的SDK,用於取得用FB登入的用入的基本資料,並加以利用

安裝

找到composer.json檔,在裡面的require以下字串

"facebook/graph-sdk": "^5.6",

然後update composer就安裝好了

設定

找到config>facebook.php

return [
    'config' => [
        'app_id' => '875839542533172',
        'app_secret' => 'e5def9309b844b03c4e7698be49d93d3',
        'default_graph_version' => 'v2.11'
    ],
];

使用

這樣就可以使用它了,下面是呼叫的方式

// 導入FB的SDK
$fb = new \Facebook\Facebook(config('facebook.config'));
$helper = $fb->getRedirectLoginHelper();

// $permissions = ['email']; // Optional permissions
$loginUrl = $helper->getLoginUrl(REDIRECT_URI.'loginthirdparty');
$button = '<a class="button button-big fb_login external" href="' . htmlspecialchars($loginUrl) . '">Facebook 登入</a>';
Previous全域變數被使用過

Last updated 5 years ago

Was this helpful?