0

ユーザーのFacebookアカウントに接続して彼の名前を取得する方法を知っているコードがあります。この関数はうまく機能しますが、問題は、ヘブライ語の名前を取得しようとすると、意味不明になることです。

charset=windows-1255 - UTF-8 も試してみましたが、まだ意味不明です。

意味不明な例: ׳׳™׳˜׳ ׳§׳•׳•׳ ׳–</p>

コード:

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>" ; ?>

ありがとう、

4

2 に答える 2

0

問題を修正しました。私のエンコーディング notpad ++ の定義は良くありませんでした。エンコーディングを utf-8 に変更する必要があります。ありがとう、

于 2010-10-17T19:05:37.900 に答える
0

SET NAMES 'utf8' を使用する必要があります。

DBに接続して値を挿入しようとするとき。

于 2011-10-13T14:09:40.190 に答える