too long

it's my first post in stackoverflow,i hope i will have the right answer for my question,because i make my researches everywhere to find a solution but nothing was helpfull...So i'm working on a zend project,and in my Facebookcontroller.php i put all the functions that i will need it to make successful connection to my website and get information about my profil.In fact it's the first time that i use this API,so i choose to use the PHP SDK.The problem is that i got always a big "0" in my $uid,so i can't recover my profile and i can not storage those informations in my database...I hope that am pretty clear,this is the code of my controller.About the facebook application i create one in www.developer.facebook.com and it works fine and i can authenticate and after that am redirected to my index.php.Thank you for your help.

<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    controller
 * @subpackage Facebook
 * @copyright  Copyright (c) 2005-2010 PHPSA . (http://www.phpsa.co.za)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: FacebookController.php 
 */
  class FacebookController extends Zend_Controller_Action
{

    public function indexAction(){

require_once 'API/facebook.php';
$appId = 'xxxxxxxxx';
$appSecret = 'xxxxxxxxxxxxxxxxxxxxxxx';

// Create your Application instance (replace this with your appId and secret).
$facebook = new Facebook( 
    array(
      'appId'  => $appId,
      'secret' => $appSecret,
    'fileUpload' => true,
    'cookie' => true

));
// Get User ID
$uid = $facebook->getUser();

if ($uid) 
{
    try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile = $facebook->api('/me');

    } catch (FacebookApiException $e) {
        error_log($e);
        $uid = null;
    }
}

// Login or logout url will be needed depending on current user state.
if ($uid) 
{
    $logoutUrl = $facebook->getLogoutUrl();
} 
    else 
    {
        $loginUrl = $facebook->getLoginUrl(
                            array(
                                'canvas' => 1,
                                'fbconnect' => 0,
                                'scope' =>'email,user_photos,user_birthday,offline_access',//these are the extended permissions you will need for your app, add/remove according to your requirement
                                'redirect_uri' => 'http://localhost:82/myProject/public/index.php',//this is the redirect uri where user will be redirected after allow,
                                ));                                       
    }

        if ($uid)
   {


    mysql_connect("localhost", "root", "");
    mysql_select_db("export"); 
    $result = mysql_query("INSERT INTO users(id, firstname, lastname, birthday, email, facebook,gender) VALUES('','$user_profile[first_name]','$user_profile[last_name]','$user_profile[birthday]', '$user_profile[email]','$user_profile[id]','$user_profile[gender]')"); 
    if (!$result)
    {
     die('Requête invalide : ' . mysql_error());
    }

  }
    else
    {
     //redirect user to loginUrl
     echo "<script>parent.location = '".$loginUrl."';</script>";
    }
}
}
?>