https://en.dpm.org.cn/visit/tickets/
The Palace Museum is limiting the daily number of visitors to 80,000, and recommending both individual visitors and tourist groups book tickets in advance online (booking address: http://gugong.228.com.cn). For detailed information and instruction, please refer to the "ticketing notice". Foreign visitors are required to provide passport numbers during the online booking.
The problem is that you need a chinese credit card to buy tickets. You need to use different websites that allow you to buy tickets by paypal.