0

This is the code I made for my facebook application but it is not giving the result. This code generate friends name, id and gender and I simply want to display in my apps. Please help me in solving the problem?

<section>
<?php
      $friends = idx($facebook->api('/me?fields=friends.limit(10).fields(gender,name)'),'data', array('access token' =>$accessToken));
?>
<div class="list">
        <h3>Your friends</h3>
        <ul class="things">
          <?php
            foreach ($friends as $friend) {
              // Extract the pieces of info we need from the requests above
                 $id = idx($friend, 'id');
            $item = idx($friend, 'name'); 
            $gender= idx($friend,'gender');

              // This display's the object that the user liked as a link to
              // that object's page.
          ?>
          <li>
          <a href="https://www.facebook.com/<?php echo he($id); ?>" target="_top">
              <img src="https://graph.facebook.com/<?php echo he($id) ?>/picture?type=square" alt="<?php echo he($item); ?>">
             <?php echo he($item); ?>
            </a>
            <?php echo he($gender); ?>
          </li>
          <?php
            }
          ?>
        </ul>
      </div>


</section>
3
Contributors
3
Replies
17
Views
4 Years
Discussion Span
Last Post by talibhassan3211
0
<?php
session_start();


# We require the library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
    'appId'  => 'XXXXXXXXXXXXXXX',
    'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'cookie' => true
));

$session = $facebook->getSession();
if ($session) {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
    $friends = $facebook->api('/me/friends');
}


foreach ($friends as $key=>$value) {
    echo '<ul id="friendsList">';
    foreach ($value as $fkey=>$fvalue) {
    if($fvalue->gender == "female") {
    echo '<li>$fvalue->name </li>';
}   
    }
    echo '</ul>';
}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.