504 Gateway timeout – api.wechat.com

Normally trying to retrieve an ACCESS TOKEN from https://api.wechat.com/sns/oauth2/access_token will return an ACCESS TOKEN used in all consecutive calls, however depending on where your servers are hosted you might be an 504 Gateway Timeout.

Solution

When you receive a 504 Gateway Timeout your first point of call should be to change all occurences of api.wechat.com to api.weixin.qq.com

Also consider replacing all occurences of admin.wechat.com to mp.weixin.qq.com

Reason

The reason this might occur is because admin.wechat.com is set to run a very specific route to China. That said certain gateways do not allow this call through.