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

阿彬
阿彬

reply all(2)
world.add(new John());

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.

  • reply Already solved, this is the method, thank you, brother
    阿彬 author 2018-09-07 17:47:34
ringa_lee

Use file_get_content directly, simple and clear

  • reply file_get_content用了 但是报错403 file_get_contents(https://api.github.com/user?access_token=17a691fd9b7843166f7dc01342deac87dee0085c): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
    阿彬 author 2018-08-29 09:41:34
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template