Facebook php app,req_perms

I am trying to make a small facebook application with php & facebook PHP API. I need to give a permissions to post status, etc. But it is doesn't work. Here is my code:

<?php
require './src/facebook.php';
$facebook = new Facebook(array(
  'appId'  => '###',
  'secret' => '###',
));

$user = $facebook->getUser();

if ($user) {
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
  echo "<a href='$logoutUrl'>Logout</a>";
} else {
  $loginUrl = $facebook->getLoginUrl(array(
       'req_perms' => 'publish_stream,read_friendlists,email'   
  ));
  echo "<a href='$loginUrl'>Login with Facebook</a>";
}

?>

When i click on Login url do not get permissions (publish_stream,read_friendlists,email). I see only "Logging in will not add this app's activity to Facebook."

First, You've got syntax error in your code. Watch these 2 lines

if ($user) {
if ($user) {

delete one of them.

Second, Do not use req_perms, but scope, which is point of your problem

This one works pretty fine

<?php 
require './src/facebook.php';
$facebook = new Facebook(array( 
  'appId'  => '##', 
  'secret' => '##', 
)); 

$user = $facebook->getUser(); 
if ($user) { 
    $logoutUrl = $facebook->getLogoutUrl(); 
    echo "<a href='$logoutUrl'>Logout</a>"; 
} else { 
    $loginUrl = $facebook->getLoginUrl(array( 
      'scope' => 'publish_stream,read_friendlists,email'    
  )); 
  echo "<a href='$loginUrl'>Login with Facebook</a>"; 
}

demo (No, I'm not collecting any data)