Here's a wireframe of how that would work:
https://www.eff.org/interoperablefacebook
Such a rule would be trivial to enforce. "Do you have an API that works" is an easy question to answer. Indeed, you can even let the system answer it itself - just legalize reverse-engineering in furtherance to federation on these lines. If new SM firms prefer to hack their way into, say, FB, then you know that FB's API isn't fit for purpose.