Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(window).load(function(){
- login();
- });
- var login = function(){
- FB.login(function(response) {
- if (response.authResponse) {
- console.log('Welcome! Fetching your information.... ');
- get_fb_info();
- } else {
- console.log('User cancelled login or did not fully authorize.');
- }
- }, {scope: 'user_about_me, friends_about_me, user_activities, friends_activities, user_birthday, friends_birthday, user_checkins, friends_checkins, user_education_history, friends_education_history, user_events, friends_events, user_groups, friends_groups, user_hometown, friends_hometown, user_interests, friends_interests, user_likes, friends_likes, user_location, friends_location, user_notes, friends_notes, user_photos, friends_photos, user_questions, friends_questions, user_relationships, friends_relationships, user_relationship_details, friends_relationship_details, user_religion_politics, friends_religion_politics, user_status, friends_status, user_subscriptions, friends_subscriptions, user_videos, friends_videos, user_website, friends_website, user_work_history, friends_work_history, email, read_friendlists, read_insights, read_mailbox, read_requests, read_stream, xmpp_login, ads_management, create_event, manage_friendlists, manage_notifications, user_online_presence, friends_online_presence, publish_checkins, publish_stream, rsvp_event, publish_actions, user_actions.music, friends_actions.music, user_actions.news, friends_actions.news, user_actions.video, friends_actions.video, user_actions:ssiz-three, friends_actions:ssiz-three, user_games_activity, friends_games_activity, manage_pages'});
- }
- <fb:login-button show-faces="true" width="200" max-rows="1" scope="user_about_me...">
- </fb:login-button>
- $user = null; //facebook user uid
- try{
- include_once 'fb-php/src/facebook.php';
- }
- catch(Exception $o){
- echo '<pre>';
- print_r($o);
- echo '</pre>';
- }
- // Create our Application instance.
- $facebook = new Facebook(array(
- 'appId' => 'YOUR APP ID',
- 'secret' => 'YOUR SECRET ID',
- 'cookie' => true,
- ));
- //Facebook Authentication part
- $user = $facebook->getUser();
- $loginUrl = $facebook->getLoginUrl(
- array(
- 'scope' => 'email,publish_stream,user_photos'
- )
- );
- if ($user) {
- try {
- // Proceed knowing you have a logged in user who's authenticated.
- $user_profile = $facebook->api('/me');
- } catch (FacebookApiException $e) {
- //you should use error_log($e); instead of printing the info on browser
- d($e); // d is a debug function defined at the end of this file
- $user = null;
- }
- }
- if (!$user) {
- echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement