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 9095299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:33:49+00:00 2026-06-16T23:33:49+00:00

I haven’t been successful to receive help on this one on stackoverflow before, I

  • 0

I haven’t been successful to receive help on this one on stackoverflow before, I already know how to pull tweets using the twitter API and how to pull facebook statuses using the Graph API .My question is this one …and I know it’s technically possible because klout.com does it . I would like to be able to let users of my websites sign in through Twitter , get the tweets of the people they follow , which already works, But at the same time , once already logged in with Twitter , I’d like to give them the option to connect to their facebook accounts , and view their FACEBOOK statuses ON TOP of their tweets of twitter and display both the tweets and FB statuses on the same page .It’s technically possible because when I log on klout.com through twitter, it gives me the option to connect my facebook account and see both my twitter and facebook data . Below is the code I tried to implement but it won’t work !!

// This twitter part works once logged in through twitter.
<?php
session_start();
require_once ('../madscore/twitter/twitteroauth/twitteroauth.php');
require_once ('../madscore/twitter/config.php');
require ('../madscore/database/connect.php');
/* If access tokens are not available redirect to connect page. */
if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
    header('Location: ./clearsessions.php');
}
/* Get user access tokens out of the session. */
$access_token = $_SESSION['access_token'];
/* Create a TwitterOauth object with consumer/user tokens. */
$handle = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
?>

       // This is the part where I call the authentications service for Facebook through the require authentication.php file , which I also copied and pasted below.
        <?php
require "../madscore/authentication.php";
// $config['baseurl'] ="../index3.php";
//if user is logged in and session is valid.
if ($fbme) {
    //Retriving movies those are user like using graph api
    try {
        $movies = $facebook->api('/me/movies');
        $pages = $facebook->api('/me/likes');
    }
    catch(Exception $o) {
        d($o);
    }
    //Calling users.getinfo legacy api call example
    try {
        $param = array('method' => 'users.getinfo', 'uids' => $fbme['id'], 'fields' => 'name,current_location,profile_url', 'callback' => '');
        $userInfo = $facebook->api($param);
    }
    catch(Exception $o) {
        d($o);
    }
    //update user's status using graph api
    if (isset($_POST['tt'])) {
        try {
            $statusUpdate = $facebook->api('/me/feed', 'post', array('message' => $_POST['tt'], 'cb' => ''));
        }
        catch(FacebookApiException $e) {
            d($e);
        }
    }
    //fql query example using legacy method call and passing parameter
    try {
        //get user id
        $uid = $facebook->getUser();
        //or you can use $uid = $fbme['id'];
        $fql = "SELECT pic_square
        FROM user 
        WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
        $param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
        $fqlResult = $facebook->api($param);
    }
    catch(Exception $o) {
        d($o);
    }
}
?>

        // This displays my twitter followers , and it works .. but below this code when i try to actually display data from facebook , nothing happens ..
        <?php
$followers = $handle->get('friends/list', array('screen_name' => $screen_name));
$json = json_encode($followers);
$array = json_decode($json, true);
shuffle($array);
if (is_array($array)) {
    foreach ($array as $value) {
        if (is_array($value)) {
            foreach ($value as $key => $second) {
                if (is_array($second)) {
                    foreach ($second as $key_second => $third) if ($key_second != 'profile_image_url') {
                        unset($key_second);
                    } else {
                        echo "<img src='" . $third . "' width='100' height='100'/>";
                    }
                }
            }
        }
    }
}
?>





 //Testing if facebook data gets returned here .. nothing happens ..

<?php var_dump($fbme); ?>

//this is the authentication file from the require statement for facebook(authentication.php)

<?php
$fbconfig['appid'] = "314216702389099";
$fbconfig['api'] = "314286708589099";
$fbconfig['secret'] = "8f803e0f9e9da4f2ba9f23ad3bd00ded";
try {
    include_once "../madscore/facebook/facebook-sdk/src/facebook.php";
}
catch(Exception $o) {
    echo '<pre>';
    print_r($o);
    echo '</pre>';
}
// Create our Application instance.
$facebook = new Facebook(array('appId' => $fbconfig['appid'], 'secret' => $fbconfig['secret'], 'cookie' => true,));
// We may or may not have this data based on a $_GET or $_COOKIE based session.
// If we get a session here, it means we found a correctly signed session using
// the Application Secret only Facebook and the Application know. We dont know
// if it is still valid until we make an API call using the session. A session
// can become invalid if it has already expired (should not be getting the
// session back in this case) or if the user logged out of Facebook.
$session = $facebook->getUser();
$fbme = null;
// Session based graph API call.
if ($session) {
    try {
        $uid = $facebook->getUser();
        $fbme = $facebook->api('/me');
    }
    catch(FacebookApiException $e) {
        // d($e);

    }
}
function d($d) {
    echo '<pre>';
    print_r($d);
    echo '</pre>';
}
?>
  • 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-06-16T23:33:51+00:00Added an answer on June 16, 2026 at 11:33 pm

    but when I try to var_dump the variable of facebook to show if I am even logged in , nothing gets returned

    You are testing the value of the variable $fbme at the very top and in the the middle of your code.

    Before you invoke the Facebook API.

    Before you actually populate the variable.

    Both of which happen at the bottom of your code.

    PHP is executed in order. You can not retrieve the value of a variable before it has been set.

    Even if your code is in order, you are completely discarding any exceptions that the Facebook API may be returning.

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

Sidebar

Related Questions

Haven't found this in my search on Stackoverflow - I know I've seen a
Haven't been able to find this one out. How are Bitmaps stored in memory
I haven't used the STL much before, but I started to on this huffman
I haven't been able to get this working and all of the sample code
Haven't been able to figure this out yet.. I've seen a few answers around
Haven't seen this before so hopefully someone has a easy solve, I have a
Haven't found anything useful about this on the internet. I'm using my Windows 7
I haven't been able to find much about this but am I the only
Haven't seen this feature anywhere else. I know that the 32nd bit is used
Haven't seen anything about it here but it seems to solve one of the

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.