views:

302

answers:

0

Hi, I am developing a facebook iframe application with the New Graph API php sdk. I am using the basic code to just display my name. But it does not return any value. Some one please help me with this.

<?php  

  include_once 'facebook.php';  
  include_once 'config.php';  

  $facebook = new Facebook(array('appId'  => FACEBOOK_APP_ID,  
                                 'secret' => FACEBOOK_SECRET_KEY,  
                                 'cookie' => true,));  

  $session = $facebook->getSession();
  $me = null;

  if ($session) {
    try {  
        $uid = $facebook->getUser();
        echo "Hello " . $uid . "<br />";   // This is displayed with my User Id

        $me = $facebook->api('/me');
       echo "Hello " . $me['name'] . "<br />";  // This is not displayed.

    } catch (FacebookApiException $e) {
        error_log($e);
    }
  }

if ($me) {
    $logoutUrl = $facebook->getLogoutUrl();
} else {
    $loginUrl = $facebook->getLoginUrl();
}

Why is my name not displayed?

Edit 1

If I use the example code that comes with the New Graph API facebook sdk zip folder, I get the following error:

 Fatal error: Uncaught CurlException: 6: 
 Could not resolve host: graph.facebook.com; 
 No data record of requested type thrown in
 C:\xampplite\htdocs\newtest\facebook.php on line 513

where line no 513 is:

 $e = new FacebookApiException(array(
    'error_code' => curl_errno($ch),
    'error'      => array(
      'message' => curl_error($ch),
      'type'    => 'CurlException',
    ),
  ));

Please explain me what is wrong. I searched for the error explanation in google,but i couldn't get much information. What is the error I have made?