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

  • Home
  • SEARCH
  • 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 3663684
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:33:30+00:00 2026-05-19T01:33:30+00:00

Please see this below PHP code: <?php require ‘../src/facebook.php’; $facebook = new Facebook(array( ‘appId’

  • 0

Please see this below PHP code:

<?php
require '../src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'xxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxx',
  'cookie' => true, // enable optional cookie support
));

try {
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
  error_log($e);
}

if ($facebook->getSession()) {     
    $friendsLists = $facebook->api('/me/friends?fields=id,name,picture,locale,email');
    $session = $facebook->getSession();

$query = "SELECT uid, name,locale,email,hometown_location FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";

$params = array(  

    'access_token' => $session['access_token'], 
    'secret' => $session['secret'],
    'sig' => $session['sig'],
    'query' =>$query  

  ); 



  $url = "https://api.facebook.com/method/fql.query?" . http_build_query($params);  
  $data = simplexml_load_file($url);  

//echo $me;

pr($data);
pr($friendsLists);

  echo '<a href="' . $facebook->getLogoutUrl() . '">Logout</a>';
} else {
  echo '<a href="' . $facebook->getLoginUrl() . '">Login</a>';
}

function pr($atr){
    echo "<pre>";
    print_r($atr);
    echo "</pre>";
}
?>

I am getting out put as below:

[user] => Array
(
    [0] => SimpleXMLElement Object
        (
            [uid] => xxxxxxxxxxxxx
            [name] => Deepak Rathi
            [locale] => en_US
            [email] => SimpleXMLElement Object
                (
                )

            [hometown_location] => SimpleXMLElement Object
                (
                )

        )

    [1] => SimpleXMLElement Object
        (
            [uid] => xxxxxxxxxxxx
            [name] => Aakriti Rovin Ranu
            [locale] => en_GB
            [email] => SimpleXMLElement Object
                (
                )

            [hometown_location] => SimpleXMLElement Object
                (
                )

        )
)

My problem is that ’email’ and ‘hometown_locations’ is empty here.I need both information in friendlist.What need to do there ..?Please give any support.

Regards
Deepak

  • 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-19T01:33:31+00:00Added an answer on May 19, 2026 at 1:33 am

    Data returned by Facebook is json encoded, not XML so I suggest you adjust your code.

    About your question – those fields are not empty, they are SimpleXMLElement Objects. Read this http://php.net/manual/en/class.simplexmlelement.php to get to know what to do next.

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

Sidebar

Related Questions

Please see the code below. Basically, when the user creates an object of this
Please see code below: s = new Socket(nextHopIP, 3434); fileIn = new FileInputStream(fileName); fileOut
I have problem with session and query execution,please see code below. class A implements
Please review the example code below, I have a class file that is loaded
It seems that i cannot access $(this) inside jquery ajax success function. please see
see code below.. <div style=overflow:auto;width:250px;height:75px;border:1px solid #336699;padding-left:5px> <label style={width:250px;}><input type=checkbox name=wow[] onclick='highlight_div(this);'> PHP</label><br> <label
*Edit: Please see my answer below for the solution. Is there any danger in
Does GWT has LazyPanel .I can not see it .Please let me know .If
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
Please See Correct Answer for solution to the requested question. Hi, Recently I have

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.