Advertisement
Guest User

facebook_oauth.php

a guest
Dec 22nd, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?php
  2. /*
  3. UserSpice 4
  4. An Open Source PHP User Management System
  5. by the UserSpice Team at http://UserSpice.com
  6.  
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. ?>
  21. <script>
  22. window.fbAsyncInit = function() {
  23. FB.init({
  24. appId : '<?php echo $settings->fbid; ?>',
  25. xfbml : true,
  26. version : 'v2.7'
  27. });
  28. };
  29.  
  30. (function(d, s, id){
  31. var js, fjs = d.getElementsByTagName(s)[0];
  32. if (d.getElementById(id)) {return;}
  33. js = d.createElement(s); js.id = id;
  34. js.src = "//connect.facebook.net/en_US/sdk.js";
  35. fjs.parentNode.insertBefore(js, fjs);
  36. }(document, 'script', 'facebook-jssdk'));
  37. </script>
  38.  
  39. <?php
  40. $db=DB::getInstance();
  41.  
  42. $settingsQ=$db->query("SELECT * FROM settings");
  43. $settings=$settingsQ->first();
  44.  
  45. $appID=$settings->fbid;
  46. $secret=$settings->fbsecret;
  47. $version=$settings->graph_ver;
  48. $callback=$settings->fbcallback;
  49.  
  50. if(!isset($_SESSION)){session_start();}
  51. //require_once("/src/Facebook/autoload.php");
  52. require_once $abs_us_root.$us_url_root.'users/src/Facebook/autoload.php';
  53. $fb = new Facebook\Facebook([
  54. 'app_id' => $appID,
  55. 'app_secret' => $secret,
  56. 'default_graph_version' => $version,
  57. ]);
  58.  
  59. $helper = $fb->getRedirectLoginHelper();
  60.  
  61. $permissions = ['email']; // Optional permissions
  62. $loginUrl = $helper->getLoginUrl($callback, $permissions);
  63.  
  64. echo '<a href="' . htmlspecialchars($loginUrl) . '"><img src="/users/images/facebook.png" alt="sign in with facebook" style="max-width: 100%;"/></a>';
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement