Facebook, Twitter pledge to defend against foreign intrusion