IPhone 6 cannot access icloud

I purchased an unlocked iPhone and everything else functions well except the iCloud. Whenever I try accessing it, it just swirls and displays an error message. It is not a problem with my internet connectivity because it just works fine on my friend's iPhone. Can anyone advise me how to go about it?
