President Donald Trump can bar The Associated Press from attending certain White House events, a federal appeals court ruled Friday.