php - I cant get user email address on facebook -


i have big problem code. try write first facebook app. code cant email user, , dont know why. can me?

require_once 'phpmailer.php'; require_once 'facebook.php';  error_reporting(0); //application configurations $app_id     = 'my app id'; $app_secret = 'my secret id'; $site_url   = 'my site url'; // create our application instance $facebook = new facebook(array(     'appid'     => $app_id,     'secret'    => $app_secret,     'cookie'=>true, ));  $user = $facebook->getuser();  if($user == 0){     $user = $facebook->getuser(); } if($user){     $user_profile=$facebook->api('/me');         $logouturl= $facebook->getlogouturl();     if(empty($_post['send'])){         echo"<form method='post'>";         echo"hi ".$user_profile['name']."</br>";          echo"<textarea name='message' rows='6' cols='80'>";         echo"</textarea>";         echo"<input type='submit' name='send' value='send'>";         echo"</form>";     }     if(!empty($_post['send'])&& empty($_post['message'])){         echo "empty message";     }     if(!empty($_post['send'])){         $mail = new phpmailer();         $mail->setfrom($_post['mail'],$user_profile['name']);         $mail->charset="utf-8";         $address="therimsilua@gmail.com";         $mail->addaddress($address," ");         $mail->subject="message facebook";         $wiadomosc='message user'.$user_profile['name'].'</br>'.$_post['message'];         $mail->msghtml($message);          if($mail->send()){             echo "send to: ".$user_profile['email'];          }         else{                        echo "error:".$mail->errorinfo;         }     }                } else {     $perm = array('scope'=>'email');     $loginurl =$facebook->getloginurl($perm);        } 

in app setting have user & friend permissions email , error ? app work fine without scope

require_once "facebook.php";  $facebook = new facebook(array('appid'  => '482455065177441', 'secret' => '0e484981225df74f1170c29185aa8690'));    $user_fb = $facebook->getuser();  if($user_fb == 0) {     $user_fb = $facebook->getuser(); }  if ($user_fb) // check user's fb user id has getting or not {    $user_profile = $facebook->api('/me');   $logouturl = $facebook->getlogouturl();   echo $user_profile['email']; echo $user_profile['first_name']; echo $user_profile['last_name'];             }  else // user's fb user id has not getting load login url email permission {       $perms = array('scope' => 'email');  $loginurl = $facebook->getloginurl($perms);          echo "<script> top.location.href='" . $loginurl . "'</script>";         } 

you doing right, email displayed users have set privacy options emails shown all, otherwise wont display email of user.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -