WASHINGTON — In “Between Two Ferns,” an off-color online parody of celebrity interview shows, the comedian Zach Galifianakis has spanked Justin Bieber with his belt, discussed Charlize Theron’s thighs and asked Natalie Portman for her phone number.

On Tuesday, Mr. Galifianakis welcomed President Obama to the comedy show that he has turned into an Internet cult favorite by making his guests feel awkward and uncomfortable.

The interview with the president, which was recorded two weeks ago, debuted online early Tuesday. The show’s creators at the website, Funny or Die, had kept its contents secret until then.

The pop-culture appearance is the latest public relations gamble that Mr. Obama and his aides have taken in their pursuit of new ways to deliver their message to the connected-but-distracted generation. “Between Two Ferns,” which satirizes the low-budget look of public access television, much as “Wayne’s World” did, has had episodes that have been viewed as many as 30 million times, often because of their outrageous content.