Wireless sensor networks (WSNs) are networks based on on the cooperation of small-sized nodes. Those nodes are mainly characterized by their low energy consumption, low cost, and wireless communication; Meanwhile, online social networks (OSNs) are becoming a popular way to meet people and keep in touch with friends. To improve the security performance in WSNs and the service quality in OSNs, trust models are commonly incorporated in both network environments. In this article, we present the first comparative study of trust models in WSNs and OSNs. We first provide a comparison of the features of WSNs and OSNs, and we provide a simple discussion of trust management in WSNs and OSNs. Next, we review and compare existing trust models for WSNs and OSNs in the literature. Finally, we conduct some discussion and point out the future directions, especially on how to enhance the trust management in a network by learning from the other type.