bitlbee/bitlbee-facebook

Make a natural language spec of the FB protocol?

Opened this issue · 7 comments

Just had an idea. What would be the feasibility of creating a natural language specification of the FB Messenger protocol, for those who need a quick reference without having to delve into the C code?

Of course, I foresee that this may not be possible, because of FB's T&Cs, but I thought I'd ask anyway.

Thanks.

Of course, I foresee that this may not be possible

Not sure what you had in mind there, but whatever it is, it's not a problem

The only reason there are no docs is that no docs have been written

Honestly, I'm not sure either.

I'm trying to decipher the C code, but I'm not sure where to start. I wanted to start documenting how FB's MQTT API works.

Get an editor that lets you jump through functions easily (I personally use vim with * or ^] and ctags) and start with fb_login in facebook.c. That starts the login and sets the callbacks that determine the flow of everything else.

Then jump like fb_api_connect -> fb_mqtt_open -> fb_mqtt_cb_open -> fb_api_cb_mqtt_open. Figure out how those functions call each other and how signals work, then extrapolate the pattern to the rest. Complement with debug output of actually running the thing, the hexdumps help a lot.

Most of the meat is in facebook-api.c. -data.c is generic storage, -http.c is a generic http client wrapper, -json.c is a generic json library wrapper, -mqtt.c is a generic (probably standard) mqtt implementation, -thrift.c is a generic compact thrift serializer and -util.c is generic garbage.

facebook-api.h has important stuff too. Also some constants in facebook-mqtt.h.

@dequis Thanks for the information. Your website helped.

I will get my editor - Emacs - to use ctags to jump through the functions later, once my exam is over today.

I guess the next big step is to figure out the model that Thrift uses, from what I've seen on your website?

Update: I'll be honest, I haven't got very far with this.
I'm not the best with C, and its all a bit confusing.. so I might leave this for a bit.

Apologies.

I tried to connect to mqtt.facebook.com on port 443 though with Paho, and it doesn't seem to like being connected to like that, which is rather odd. Just thought I'd mention.