PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 21, 2022

[FIXED] How to avoid my this facebook app api login page?

 February 21, 2022     facebook, facebook-php-sdk     No comments   

Issue

I got a problem regrading with my apps which is once I go to my apps, it sure will show me a login page instead of allow page?

it always display the login page 1st then only display allow page, I had tried other apps, if I am 1st time user, It sure will appear the allow page only, it did not show me the login page.

my question is how to I avoid my login page direct go to allow page?

here is my login page picture enter image description here

here is my apps link

https://apps.facebook.com/christmas_testing/

here is my facebook php jdk api coding

<?php
$fbconfig['appid' ] = "XXXXXXXXXXXXX";
$fbconfig['secret'] = "XXXXXXXXXXXXX";
$fbconfig['baseUrl']    =   "myserverlink";
$fbconfig['appBaseUrl'] =   "http://apps.facebook.com/christmas_testing/";

if (isset($_GET['code'])){
    header("Location: " . $fbconfig['appBaseUrl']);
    exit;
}
if (isset($_GET['request_ids'])){
    //user comes from invitation
    //track them if you need
     header("Location: " . $fbconfig['appBaseUrl']);
}

$user   =   null; //facebook user uid
try{
    include_once "facebook.php";
}
catch(Exception $o){
    echo '<pre>';
    print_r($o);
    echo '</pre>';
}
// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => $fbconfig['appid'],
  'secret' => $fbconfig['secret'],
  'cookie' => true,
));

//Facebook Authentication part
$user = $facebook->getUser();

$loginUrl   = $facebook->getLoginUrl(
        array(
            'scope' => 'email,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown'
        )
);
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;
}

//get user basic description
$userInfo = $facebook->api("/$user");

function d($d){
    echo '<pre>';
    print_r($d);
    echo '</pre>';
}

?>


Solution

This is an effect of the new auth dialog features facebook recently rolled out.

There are two "allow/login" screens when using this new dialog :

  • Regular permissions such as - user_about_me, user_birthday, user_photos.
  • Extended permissions such as - read_insights, offline_access, publish_actions.

Each will display its own dialog. First the regular permissions will appear and after that the extended permissions will appear (if you have requested extended permissions)... This happens when the user first logs in, and possibly later if you want decide to add additional permissions to your app.

Taken from the Open Graph Beta › Auth Dialog

The updated Auth Dialog will display a set of user and friends permissions on the first dialog, and other extended permissions (if any) on a second dialog screen.

You can disable this feature and go back to the older auth dialog by changing the setting inside your app. Goto the advanced tab in the settings of your app and uncheck the Enhanced Auth Dialog check-box.



Answered By - Lix
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing