Facebook PHP SDK is shadow IT

Part 1 in a series of articles: Social Media APIs [developers]. And today: Why NOT to use Facebook API PHP SDK.

Are you developing for social media and trying to hook to the Facebook API by using the Facebook PHP SDK? Well, I feel sorry for you. The Facebook PHP SDK is full of bugs, full of obscured code, and is very hard to use. I hereby give you several reasons why NOT to use it, and probably NOT to use any other social media SDK / framework as they are closer to be in the shadow IT category than in anything else.

1. Have ownership of your code
The first thing that a professional has to take care of, is ownership of the knowledge, and developers are no exception to that! When you use heavy frameworks with thousands of lines of codes which you didn’t write, you wouldn’t have the chance to own the code: it is just too complicated. Of course that with some frameworks – like Jquery – you don’t want to reinvent the wheel – but when it comes to hooking to 3rd party API, and especially sites like Facebook, Twitter and LinkedIn which you would continue to use for long time, better that you write your own code: in the end, it is not so complicated and wouldn’t require you more time than to try to understand what others did when they compiled the SDK.

2. Bugs
The nature of large pieces of code, that they have bugs. It means that you would need to patch it and upgrade it, and not by your own demand – but when bugs are found in the system. This is of course in the scenario that you are lucky and not the first one to experience the bugs.

3. Unexpected upgrades
When you use 3rd party frameworks, you should expect to be required to upgrade it, and not necessary on the best timing which would be convenient for your project.

4. PHP SDK is Inefficient code
When you look at Facebook’s PHP SDK, you find lots of functions and variables which you would never use. The code itself looks very heavy to what you want to do. Some people claim that Facebook wins the “worst API in developers survey”, which is probably because they haven’t tried the LinkedIn SDK, which is even worst! Anyway, back to the efficiency point, the Facebook SDK starts by including lots of libraries… it looks something like that:

use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\GraphUser;

If you think that these are all the libraries you need to include – then you are wrong: we once tried to use it for posting on our Facebook wall, we needed 7 libraries and 2,000 lines of code, and that was even before we started anything.

5. PHP SDK is shadow IT
The Facebook PHP SDK code is written as a complete framework, which means that lots of functions and lots of variables are lying down in the backend, and you will never really use or seen. This is a typical shadow IT issue which refers to point 1 above: have ownership of your code!

Facebook API PHP SDK seems to be well managed, but the end result looks like a shadow IT product
Facebook API PHP SDK seems to be well managed, but the end result looks like a shadow IT product

6. Object Oriented Frameworks suck!
There is a generic issue with Object Oriented (OO) frameworks: they are just too complicated. OO is useful; when you are dealing with objects… we plan to dedicate a whole article for the “OO vs Functional programming debate”. However, API calls are not “objects”, they are not combined of parts, which include other parts, which include other basic parts – these are just bloody API calls, nothing could be simpler than just calling the API directly.

7. Hard to use
The Facebook API is complicated enough, that it may take you time to know which API call with which variables, you may want to do. Now add on top of it another layer of complexity: how to use the PHP SDK, and you may find yourself digging days and nights into trying to understand “how the hell the SDK can do that API call”, while if you did it with direct call, you won’t have that complexity at all.

8. Horrible documentation
The Facebook API documentation is not so good, but comparing to Twitter and LinkedIn it is a master piece that should get a noble prize in literature: this is because the Twitter API documentation looks like was written but a non English speaker which does not know anything about development, it almost looks like they wrote it in order to fail you on purpose. OK so back to Facebook API – the API documentation is OK, however the PHP SDK documentation is horribly bad: if you like to play “hide and seek”, yes – please go ahead and use it.

So hopefully I convinced you that Facebook PHP SDK sucks. Even if not, in the next articles we will be more practical and show you how easy it could be to access the Facebook API with direct https calls, it is so easy that you may be convinced to dump the PHP SDK. We will share our core lines of code with you, and even if you are a newbie to Facebook API and/or to PHP, you may be able to cut and paste our code and use it without any troubles.




Leave a Reply

Your email address will not be published. Required fields are marked *