views:

39

answers:

1

hi guys, i have code that know how to connect to user facebook account,and take his name. this function does works well, the problem is , when i try to get hebrew name, than i get gibrish.

charset=windows-1255 - i tried UTF-8 too, and still i have gibrish.

for gibrish example: ׳׳™׳˜׳ ׳§׳•׳•׳ ׳–

the code:

require 'src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => '1294881225',
  'secret' => '6d28eq8fe1',
  'cookie' => true,
));

$session = $facebook->getSession();

$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}

// login or logout url will be needed depending on current user state.
if ($me) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId   : '<?php echo $facebook->getAppId(); ?>',
      session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
      status  : true, // check login status
      cookie  : true, // enable cookies to allow the server to access the session
      xfbml   : true // parse XFBML
    });

    // whenever the user logs in, we refresh the page
    FB.Event.subscribe('auth.login', function() {
      window.location.reload();
    });
  };

  (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

<?php echo "<font color=white>name: "  . $me['name']  . "</font>" ; ?>

thanks,

A: 

hi guys, i fix the problem, the definition of my encoding notpad ++ was not good, ou need to change the encoding to utf-8. thanks,

ROI