简体   繁体   中英

Facebook graph api redirects to redirect_url/index.php in codeigniter

I want to use fb graph api in code igniter. The file is:

$app_id = 'xxxx';
$app_secret = 'xxxx';
$redirect_url='http://onlineislamicquiz.net/facebook';

//3.Initialize application, create helper object and get fb sess
FacebookSession::setDefaultApplication($app_id,$app_secret);
$session="";
$helper = new FacebookRedirectLoginHelper($redirect_url);
try 
{
    $session = $helper->getSessionFromRedirect();
} 
catch(FacebookRequestException $ex) 
{
    echo "Facebook returns error";
} 
catch(\Exception $ex) 
{
    echo "There are some issues in your app";
}

// Setting facebook token to check whether user has logged in or not

if ( isset($_SESSION['fb_token']))
{
    $session = new FacebookSession($_SESSION['fb_token']);
    echo "Session exists already";
}
// The Url for logging out

if (!$session) 
{
    //store the session in a token 

    //else echo login
    echo '<a href='.$helper->getLoginUrl(array('email')).'>';
    ?>
    <button class="btn btn-primary">Sign up with : <i class="fa fa-facebook-square fa-2x"></i></button>
    <?php
    echo '</a>';
}

There is a controller at :

http://onlineislamicquiz.net/facebook

which handles backend.

I want to redirect to the:

http://onlineislamicquiz.net/facebook

But, it redirects me to:

http://onlineislamicquiz.net/facebook/index.php?code=AQAjmLnAEQL1yD8alM1yneGQMmWEVWNDsIF6aKra5xr7k2EQqyPkybo84-vbHRjQw1Nt2Fb3bdn4pbSN9w1WarRF7GkF3Q1nrZ--n0aHPqZ4x9p54vei7qsrHk-zidAHQAGRd8kZl-6Cs8uDpJoIEORV8bFiY8XssjeoXExAFIWh6uQAVOO4HqOqxKGPz3siGpXh_ogUScGbJCyo2IAak_gu5rGR8L9mQpsCOQZsss6RMdTIJNGYWXp7vxSYryB-Ekr4uYRhWGGC-GHfxAMD0nYHKioGqPZPt-bkgQDDSa_vBxJIgjUpgj5nnTs9X3sgohy0MdjG3sNmhbIPX9WHPPQM&state=cc43abcbabab5072447a0faa26b36d27# =

which is not found. The htaccess is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

<Files "index.php">
AcceptPathInfo On
</Files>

Looks like there is something wrong with .htaccess. Please help me to solve this.

try it RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM