Many websites use the third-party account login function (which is basically implemented through OAuth 2.0). If your website or project needs to implement such a function, it is actually very easy. The following describes the open APIs provided by Sina Weibo.
1. Apply for an appkey and appsecret on the Weibo open platform, and fill in various materials
2. Program Development
The Sina Weibo open platform provides sdks for download, and we can use the ready-made Sina Weibo OAuth certification class in it, which is named SaeTOAuthV2.
I provide a ready-made file for download, which not only includes the SaeTOAuthV2 class, but also encapsulates the SaeTClientV2 class for various Sina Weibo interfaces. In fact, we don't need it, or we can build our own classes based on the APIS it provides. (I am using the php language)
1) the first step of Sina Weibo OAuth authentication process is to direct the user to the Sina Weibo OAuth authentication page, so we need to get the url of this page.
Let's talk about $ callback_url, which means that after Sina authentication, the url page you specified will jump to. On this page, you can process the authentication result. In addition, we generally perform authentication in code mode, that is, the second parameter of the getAuthorizeURL function. For other authentication methods, refer to Sina's documentation.
2) The second step is to process the authentication result on the callback page $ callback_url.
After you log on to and authorize the Sina Weibo OAuth page, you will be redirected to the specified $ callback_url page. In addition, the url of this page contains a code parameter, this parameter is provided by sina. We use the value of this code parameter to obtain the access_token.
Note that the $ token we get is an array, and $ token ['Access _ token'] is the real access_token token. We can store it in sessions for future calls.
3) Step 3, with the access_token token, we can access various api interfaces provided by Sina Weibo.
For more information about the APIs and Their returned results, see the Sina api documentation. json data is returned.
After obtaining the access_token, it indicates that we can use the api to obtain information about the Sina Weibo user. With this information, we can develop the login function, such as binding an account.
Well, it's that simple. It's easy to understand the process.