What the heck? Are Developers of Facebook client libraries for ASP.NET stupid?

Posted by Dmytro Shteflyuk on under ASP.NET

Last week I faced strange bug in Facebook Developer Toolkit. When I tried to call setFBML method (I mentioned it in my previous post) I’ve got an exception about invalid signature. “Haha” I said and downloaded toolkit sources. After some debugging, I’ve found a few lines which just killed me:

// Compute the MD5 hash of the signature builder
hash = md5.ComputeHash(Encoding.Default.GetBytes(

Just take a look into the MSDN’s topic about Encoding.Default: Gets an encoding for the system’s current ANSI code page. And below we can find Caution:

Different systems might use different encodings as the default; therefore, data streamed from one system to another might be translated incorrectly. To ensure that the encoded bytes are decoded properly, use a Unicode encoding (that is, UTF8Encoding, UnicodeEncoding, or UTF32Encoding) with a preamble. Another option is to use a higher level protocol to ensure that the same format is used for encoding and decoding.

Holly shit! Guys, did you read MSDN before writing libraries for others to use? I think you didn’t.

Anyways, I have fixed my local copy:

// Compute the MD5 hash of the signature builder
hash = md5.ComputeHash(Encoding.UTF8.GetBytes(

Of course, it started working perfectly. I have posted a bug to the tracker and decided to look at the Facebook.NET, a better and much cleaner implementation according to AjaxNinja.

And what do you think? Just open CreateSignature method in Framework/Service/Core/FacebookRequestParameterList.cs file:

byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(sigBuilder.ToString()));

Craaaaaaaaaaap. My brain exploded! I don’t know what to do. I don’t know, how to explain to all developers about non-ASCII code pages. We are living in world that is not ideal. We have tons of languages, encodings, code pages. And we have UTF8, which should simplify our life. Hey, guys, WTF?

Updated 23 Sep 2007: Facebook.NET developers has closed this bug. Hope I will never see something like this again. Facebook Development Toolkit still does not working for me. I see 27 open bugs in its tracker, so I decided to use Facebook.NET.

15 Responses to this entry

Subscribe to comments with RSS

said on September 19th, 2007 at 09:37 · Permalink

нихуя не понял :)

чего кричим? :)

said on September 19th, 2007 at 10:32 · Permalink

Кричим потому что автор судя по всему впервые нашел ошибку в публичной библиотеке – вот и пребывает в ейфорическом настроениеи по этому поводу.

said on September 19th, 2007 at 10:43 · Permalink

Если бы в первый… И если бы только в одной библиотеке… Просто очень бесит, когда буржуйские товарищи забывают про то, что они не одни на планете. Уже тыщу миллионов раз писалось про кодировки, про юникод и все остальное. И тут на тебе. Обе более-менее приличные библиотеки Facebook с таким дурацким багом.

said on September 19th, 2007 at 10:57 · Permalink

а чё они должны про вас помнить? :) денег-то платят в основном буржуины за он-лайн сервисы, вот на целевую аудиторию и работают.

said on September 19th, 2007 at 14:10 · Permalink

со своей колокольни лучше видно, а попади в такую ситуацию – тоже кричал бы ;)

З.Ы. Я и сам находил ошибки в либах Facebook, но под PHP

said on September 22nd, 2007 at 13:14 · Permalink

это нормальная практика, “они” там думают, что кроме них самих это больше никому не понадобится :)
когда-то столкнулся с подобной проблемой в NuSOAP, там тупо utf-8 сливался в Latin-1 при этом все нелатинские символы превращались в вопросительные знаки… :)

said on September 22nd, 2007 at 21:56 · Permalink

Тоже находил ошибки в клиенте для фейсбука и под 4-й и под 5-й пхп. В первых версиях либы для пхп4 приходилось убирать куски try catch =/

said on November 10th, 2007 at 00:53 · Permalink

encountered same bullshit and resolved with same trick…

yeah… whatthefck++;

said on November 23rd, 2007 at 10:36 · Permalink

I just happened upon this post from a link on the Facebook Developer’s Forum and I find a link to my blog lol! How’ve you liked Facebook.NET so far? I like it way better than the Facebook Developer Toolkit, although I have had to make my own hacks similar to yours (I actually blogged about it today) in order to get some of the functionality I need out of Facebook.NET.

Are you still developing FB applications in .NET?

said on November 23rd, 2007 at 12:03 · Permalink

Hi, Aaronontheweb
First of all, thank you for your blog :-)
I like Facebook.NET, except one thing: Nikhil hides results of the Facebook web-service call (right, you have blogged about this already). Anyway, it’s much better than Developer Toolkit as for me :-)

PS. Yes, I’m working currently on Facebook application. Hope, it will be finished soon, so I will blog about it.

said on January 14th, 2008 at 22:27 · Permalink

LOOL, mate!
This is great! I wish people like you were creating this sort of libraries. The other option is to create everything from scratch. I had to do the same thing with the protx.com protocol as the guys that are responsible for it created some kind of a monster ;].

Kevin Marshall
said on January 23rd, 2008 at 00:46 · Permalink

I admit I’m somewhat defensive since I worked on the Facebook Developer Toolkit, but in the time it took you to complain about the bug you could have fixed it. That’s kind of the point of open source software, use it and contribute back to it.

Oh wait, you did fix it on your local copy. That’s helpful.

I haven’t worked on it since the original release, but dozens of other developers have spent their own free time working on it. Being a dick about it really isn’t helpful to the community development effort.

Great, you’re smarter than the rest of us and write better code. Congrats.

said on January 23rd, 2008 at 10:10 · Permalink

Hey Kevin,

As you could see, I have posted a bug to the Facebook Developer Toolkit bug tracker, along with fix. So maybe I’m dick, but I have tried to help community to build better software.

Comments are closed

Comments for this entry are closed for a while. If you have anything to say – use a contact form. Thank you for your patience.