Search code examples
phpfacebookcodeigniterfacebook-graph-api

Login with Facebook using codeIgniter PHP in localhost


I have done an application in my localhost for login with Facebook using PHP and codeigniter. I have created an app in https://developers.facebook.com/apps/ and I got the app id and secret key. But I am getting the following warning when trying to access.

Warning
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.

I am using wamp server and following details for Facebook app:

I also have one config file named facebook.php with following code:

$config['facebook_app_id']              = 'MyAPPId';
$config['facebook_app_secret']          = 'SecretKey';
$config['facebook_login_type']          = 'web';
$config['facebook_login_redirect_url']  = 'signin';
$config['facebook_logout_redirect_url'] = 'home';
$config['facebook_permissions']         = array('public_profile', 'publish_actions', 'email');
$config['facebook_graph_version']       = 'v2.9';
$config['facebook_auth_on_load']        = TRUE;

I tried so many things and nothing worked. Any solution?


Solution

  • The problem is solved. I have modified my Facebook.php config file as follows: `

    $config['app_id']                       = 'MyAPPID';
    $config['app_secret']                   = 'SecretKey';
    $config['facebook_login_type']          = 'web';
    $config['facebook_login_redirect_url']  = 'index.php/signin';
    $config['facebook_logout_redirect_url'] ='index.php/home';
    $config['facebook_permissions']         = array('email','user_location','user_birthday');
    $config['facebook_graph_version']       = 'v2.9';
    $config['facebook_auth_on_load']        = TRUE;
    

    `

    Reference Link : https://www.codexworld.com/facebook-login-codeigniter/

    Thanks