PHP if user is on a list

Using the API and PHP how can we show content or give access to areas based on if a user is on a Hubspot list or not. For example:

if (user is on list YYY) {

 show THIS

} else {

 show THAT
}

If possible you may not need PHP at all. HubSpot exposes the lists a contact is associated with in a page request variable called request_contact.list_memberships. That may not work for your use case though. I think the other option is to use the lists API to get the contacts in a specific list and then see if the one you have is in it. I’d be interested to know if there is a better way.