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

Tuesday, February 15, 2022

[FIXED] Facebook App Login Error

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

Issue

I've been looking everywhere for a solution to my problem, but to no avail so far.

I'm following steps to create a Facebook app from a Facebook Tutorial and I've run into a problem in the logging in process even though I seem to be doing everything correctly. When the app tries to login, I get the following error:

Given URL is not permitted by the application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

You would think that there's something wrong with my app configuration, but that doesn't seem to be the case. Here's a screenshot:

enter image description here

The canvas URL is correct and I've tested with or without the App Domains field filled out. Here is the php for the login:

<?php
    require 'server/fb-php-sdk/facebook.php';

    $app_id = '236534686497558';
    $app_secret = '***************************';
    $app_namespace = 'mytestsmash';
    $app_url = 'https://apps.facebook.com/' . $app_namespace . '/';
    $scope = 'email,publish_actions';

    // Init the Facebook SDK
    $facebook = new Facebook(array(
         'appId'  => $app_id,
         'secret' => $app_secret,
));

// Get the current user
$user = $facebook->getUser();

// If the user has not installed the app, redirect them to the Login Dialog
if (!$user) {
        $loginUrl = $facebook->getLoginUrl(array(
        'scope' => $scope,
        'redirect_uri' => $app_url,
        ));

        print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
}
?>

I can't figure out what's going wrong here.


Solution

Realized the issue was the $app_url was httpS in the php... but the canvas page url in the settings was just http!



Answered By - dlofrodloh
  • 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