Take the 2-minute tour ×

I keep getting the error in the title, while using a simple code:

function idx(array $array, $key, $default = null) {
  return array_key_exists($key, $array) ? $array[$key] : $default;
function he($str) {
  return htmlentities($str, ENT_QUOTES, "UTF-8");
$facebook = new Facebook(array(
  'appId'  => AppInfo::appID(),
  'secret' => AppInfo::appSecret(),
  'sharedSession' => true,
  'trustForwarded' => true,

$user = $facebook->getUser();
$friends = idx($facebook->api('/me/friends'), 'data', array());
if ($friends) {

I really don't know how to solve it, I've been searching and trying many answers on stackoverflow

share|improve this question
Please follow instructions on this link:- stackoverflow.com/questions/11776234/… –  Mudaser Ali Aug 15 '13 at 12:01
add comment

2 Answers

You need to set the access token to be able to get data or act on behalf of the user. Are you going through a login flow to allow authorization to your Facebook application?

Try the example at https://developers.facebook.com/docs/reference/php/facebook-api/

It provides the very basic login flow that will grant access to the data you're seeking.

share|improve this answer
add comment

You are not accessing the graph API with a user access token. In fact, you're not using a token at all. Please familiarize yourself with Facebook authentication using this link.

share|improve this answer
add comment

Your Answer


