Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7405717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:26:44+00:00 2026-05-29T05:26:44+00:00

I’m creating a simple proof-of-concept web-app that integrates with Facebook. The base functionality is

  • 0

I’m creating a simple proof-of-concept web-app that integrates with Facebook. The base functionality is that it needs to display basic info about the user, and a few of their friends + friend profile pictures. All of it seems to work, minus logging out – when the user clicks the logout link on my web app, which is generated via the Facebook PHP-SDK, the page simply appears to refresh – the user is clearly still logged into my web app. They are, however, logged out of Facebook proper. Any idea why I’m seeing this behavior? My code is as follows:

<?php

require 'sdk/facebook.php';

$facebook = new Facebook(
    array(
        'appId' => 'xxx' //actual app ID and secret go here,
        'secret' => 'xxx'
    )
);

##
## Instantiate user object if a logged in user exists
if ($user = $facebook->getUser()) {
    try {
        $user_profile = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        $user = NULL;
    }
}

##
## Set login/logout url
$url = $user ? $facebook->getLogoutUrl() : $facebook->getLoginUrl();

##
## Instantiate friend object data
if ($user) {
    try {
        $friend_api_data = $facebook->api('/me/friends');
        $friends = $friend_api_data['data'];
        // Shuffle friends
        shuffle($friends);
        $shuffled_friends = array();
        for ($i = 0; $i < count($friends) && $i < 6; $i++) {
            $shuffled_friends[] = $friends[$i];
        }   
    } catch (FacebookApiException $e) {

    }

}

?>
<!doctype html>
<html>
<head>
    <title>Test</title>
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="container">
        <h1>Facebook Integration</h1>

        <!-- Login/Logout URL -->
        <a href="<?= $url ?>"><?= $user ? 'Logout' : 'Login' ?></a>

        <!-- Current User Data -->
        <?php if ($user): ?>
            <h2>Hi, <?= $user_profile['name'] ?></h2>
            <img src="https://graph.facebook.com/<?= $user ?>/picture" />

            <pre>
                <?= print_r($user_profile, TRUE) ?>
            </pre>
        <?php endif; ?>

        <!-- Friend Data -->
        <?php if($shuffled_friends): ?>
            <h2>Your Friends</h2>
            <ul>
                <?php foreach($shuffled_friends as $f): ?>
                    <li>
                        <a href="http://www.facebook.com/<?= $f['id'] ?>">
                            <img src="https://graph.facebook.com/<?= $f['id'] ?>/picture" />
                            <?= $f['name'] ?>
                        </a>
                    </li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
    </div>  
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:26:44+00:00Added an answer on May 29, 2026 at 5:26 am

    If your using version 3 of the PHP SDK, you’ll also need to call the destroySession function as it saves the user data in a session.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.