user3336908
user3336908

Reputation: 1

Redirect Url not working properly

I am trying to access facebook contacts, the code works fine but when in try to logout , the redirect Url doesnot work, Instead it is Redirected to the User's Facebook home page.

<?php
require './src/facebook.php';
$facebook = new Facebook(array(
    'appId' => 'App ID',
    'secret' => 'App Secret',
));
$user = $facebook->getUser();
if ($user) {
    $facebook->destroySession();
    header("location: skifi.zapto.org/affiliates/index.php");
}
?> 

index.php

<?php
$file = dirname(__FILE__) . '/src/facebook.php';
if (file_exists($file)) {
    require dirname(__FILE__) . '/src/facebook.php';
} else {
    echo 'Facebook SDK Not Found';
    exit;
}

$facebook = new Facebook(array(
    'appId' => 'App ID',
    'secret' => 'App Secret',
));

$user = $facebook->getUser();

if ($user) {
    try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');
        $friends = $facebook->api('/me/friends');
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}

Upvotes: 0

Views: 99

Answers (2)

Shairyar
Shairyar

Reputation: 3356

This is how I do it, seems to be working on my localhost.

$redirect_page = "http://skifi.zapto.org/affiliates/index.php";
header('Location: ' . $redirect_page);
exit();

Upvotes: 0

OpenStark
OpenStark

Reputation: 486

Try with Location with a capital L and http://

header("Location: http://skifi.zapto.org/affiliates/index.php");

http://www.php.net/manual/fr/function.header.php

Upvotes: 2

Related Questions