修复 Facebook 上的希伯来语问题
我有代码知道如何连接到用户 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我解决了这个问题,我的编码 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,
你应该使用
设置名称'utf8';
连接到数据库并尝试插入值时。
you should use
SET NAMES 'utf8';
when connecting to the DB and trying to insert the values.