For many nations, this tends to be quite a tedious process when travelling to foreign countries. However, when it comes to China, there is likely to be several conditions to be met before you being able to enter the nation.
For example, if you are hoping to visit, then you will need to present an invitation letter from a friend or you will need to submit a full itinerary of your stay as well as several other pieces of documentation prior to being granted a visa.
It is common practice to ensure that you apply for your visa much earlier than you plan to visit as the entire process can take several weeks to several months based on the time of the year and the type of visit you plan to make.