Failed to obtain user information when logging in with GitHub account
阿彬2018-08-28 18:01:47
0
3
1224
When logging in to GitHub, I found that directly using curl to simulate a get request cannot obtain user information, but pasting out the link can return information when the browser directly accesses it. Please tell me how to request it in PHP
GitHub's documentation says that when calling the API, the request header needs to contain User-Agent, so directly file_get_content will produce a 403, and then the browser can access it. The solution is to use curl to simulate a get request and add User-Agent to the header of the request. You can copy the value from the browser.
GitHub's documentation says that when calling the API, the request header needs to contain User-Agent, so directly file_get_content will produce a 403, and then the browser can access it. The solution is to use curl to simulate a get request and add User-Agent to the header of the request. You can copy the value from the browser.
Use file_get_content directly, simple and clear