修复 Facebook 上的希伯来语问题

发布于 2024-09-27 22:46:29 字数 1710 浏览 4 评论 0原文

我有代码知道如何连接到用户 Facebook 帐户,并获取他的名字。 这个函数确实工作得很好,问题是,当我尝试获取希伯来语名称时,我得到的是乱码。

charset=windows-1255 - 我也尝试过UTF-8,但仍然有乱码。

对于乱七八糟的例子: ೳ™׳~׳ §׳•׳•׳ ׳–

代码:

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

谢谢,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安静 2024-10-04 22:46:29

我解决了这个问题,我的编码 notpad ++ 的定义不好,
需要将编码更改为utf-8。
谢谢,

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

大姐,你呐 2024-10-04 22:46:29

你应该使用
设置名称'utf8';

连接到数据库并尝试插入值时。

you should use
SET NAMES 'utf8';

when connecting to the DB and trying to insert the values.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文