gerbenjacobs / HabboAPI

A PHP wrapper for the (undocumented) Habbo API
MIT License
44 stars 10 forks source link

Special character problem in username #48

Closed talhatokur closed 4 years ago

talhatokur commented 4 years ago

I need motto authentication to register users on fansite and I'm having trouble registering users with special characters (ö, ş, ğ, ı, etc.), looking for a solution.

gerbenjacobs commented 4 years ago

Are you sure UTF-8 is enabled on your site/form? Also are you getting errors, if so what?

talhatokur commented 4 years ago

I wrote the username (şük) and got the following error.


Oops. Can not find this Habbo!

Try to catch this exception gracefully in your application!

[0] Unknown HabboAPI exception occurred: An unknown HTML page was returned


0 D:\xampp\htdocs\habboApi\vendor\gerbenjacobs\habbo-api\src\HabboParser.php(244): HabboAPI\HabboParser::throwHabboAPIException(' #1 D:\xampp\htdocs\habboApi\vendor\gerbenjacobs\habbo-api\src\HabboParser.php(68): HabboAPI\HabboParser->_callUrl('https://www.hab...', true)

2 D:\xampp\htdocs\habboApi\vendor\gerbenjacobs\habbo-api\src\HabboAPI.php(47): HabboAPI\HabboParser->parseHabbo('\xC5\x9F\xC3\xBCk', false)

3 D:\xampp\htdocs\habboApi\api.php(25): HabboAPI\HabboAPI->getHabbo('\xC5\x9F\xC3\xBCk')

4 {main}


I understand that there is something encoded somewhere, I did not get any effect even though I made the character encoding utf-8.

I tried two ways to fix it, I corrected the encoding of characters, but this time the special letters returned as a question mark.


$habbo = @$_GET["user"];
if (mb_detect_encoding($habbo, 'utf-8', true) === false) {
        $habbo = mb_convert_encoding($habbo, 'utf-8', 'iso-8859-1');
    }

$myHabbo = $habboApi->getHabbo($habbo);

This didn't work, it turned the same.

I tried a second way.

$myHabbo = $habboApi->getHabbo(mb_convert_encoding(utf8_decode($habbo), 'utf-8', 'iso-8859-1'));

This time it worked, but special characters just returned as question marks. I couldn't reach my goal. This is a necessary system for me, I think there is a character loop somewhere, I expect your response as soon as possible :)

gerbenjacobs commented 4 years ago

I think the problem your form/page is not UTF-8. If you say the second way works, but the page shows question marks afterwards then that's probably an indication.

talhatokur commented 4 years ago

I am primarily sending UTF8 encoding,

header("Content-Type: text/html; charset=utf-8");


But nothing has changed.
Because there is no problem with special characters in a normal string value.


$username = "şçöğüı"; echo $username
Output : şçöğüı



In this case, the output turns out to be normal, but special characters return very differently when using functions.

$myHabbo = $habboApi->getHabbo("şçöğüı");

The whole problem arises when I use this function, whereas the site has utf8 encoding. I think there is a system-related error, could you please try and solve the error on the workspace? thx