php - get facebook user gender using facebook graph api -
i made code display user's friends , name,id , profile pic of friend. problem gender of friend , made code below first code .but not seems work works in case of getting gender information .
function displayusersicons($criteria) { $users = $criteria['users']; $nb_display = $criteria['nb_display']; $width = $criteria['width']; echo 'data'.$gen = $criteria['gen']; if($width=='') $width="200"; if($nb_display>count($users) || $nb_display=='') $nb_display=count($users); //display value never bigger nb users $display = ''; for($i=0;$i<$nb_display;$i++) { $name = $users[$i]['name']; $picture = $users[$i]['picture']; $url = $users[$i]['url']; $user_id = $users[$i]['id']; $cookie = self::$cookie; if($cookie['access_token']!='') { $url = 'https://graph.facebook.com/'.$name.'?access_token='.$cookie['access_token']; //echo '<a href="'.$url.'" target="_blank">'.$url.'</a><br>'; $data = json_decode($this->getdatafromurl($url)); $fb['gender'] = $data->gender; $gender=$fb; $display .= '<li class="mispan main-span" gen="'.$gender.'" data="'.$user_id.'" unme="'.$name.'" upic="'.$picture.'">'; $display .= '<div class="thumbnail">'; $display .= '<h3 class="miheader">'.$name.'</h3>'; $display .= '<a href="'.$url.'" target="_blank" title="'.$name.'">'; $display .= '<div class="miprofile-pic-cnt" style="background-image:url('.$picture.')" ></div>'; $display .= '</a>'; $display .= '<div class="caption" style="text-align:center;">'; $display .= '<p><a href="#" class="btn kssico miclickks"><img src="iconos/lips.png" /></a> <a href="#" class="btn bdico miclickbd"><img src="iconos/bed.png" /></a></p>'; $display .= '</div>'; $display .= '</div>'; $display .= '</li>'; } return $display;
}
the code friends gender
$cookie = self::$cookie; if($cookie['access_token']!='') { $url = 'https://graph.facebook.com/'.$name.'?access_token='.$cookie['access_token']; //echo '<a href="'.$url.'" target="_blank">'.$url.'</a><br>'; $data = json_decode($this->getdatafromurl($url)); $fb['gender'] = $data->gender; $gender=$fb;
http://graph.facebook.com/<facebook_id>?fields=gender
fields=gender
gives gender given facebook id.
Comments
Post a Comment