Know your professional guidelines for doing research. In the US, know your American Psychological Association guidelines. In the UK, know your British Psychological Society guidelines. Where ever you are, know the guidelines.
More generally, there is The International Compilation of Human Research Standards - 2014, which "enumerates over 1,000 laws, regulations, and guidelines that govern human subjects research in 107 countries," The Belmont Report of 1979, and The Nuremberg Code of 1947 (yes, that Nuremberg).
As for the Facebook study, I believe that the Proceedings of the National Academy of Sciences (PNAS), the academic journal that published the study, should withdraw, dismiss, remove it. The tainted fruit of the poisonous tree.
However, despite a tepid apology from Facebook, the academic institutions and the PNAS journal still appear to be in some time-warped Nixonian "hunker down" denial mode. They should know better.