Home > Backend Development > PHP Tutorial > ucenter communication principle, ucenter_PHP tutorial

ucenter communication principle, ucenter_PHP tutorial

WBOY
Release: 2016-07-13 10:20:15
Original
1095 people have browsed it

ucenter communication principle, ucenter

1. The user logs in to discuz and verifies the posted data through the function uc_user_login in the logging.php file, that is, verifying the username and password.

2. If the verification is successful, the function uc_user_synlogin located in the client.php file under uc_client will be called. In this function, uc_api_post('user', 'synlogin', array('uid'=>$ uid)).

3. Then this function passes data to index.php of Ucenter. Index.php accepts the passed data and obtains the value of model as user and action as synlogin.

4. Then Ucenter’s index.php calls the onsynlogin method in the user.php class in the control directory, and uses javascript to notify the applications in the uc application list that enable synchronous login through the foreach loop to log in synchronously; That is, some data is passed to uc.php under the api in each application directory through get method.

5. uc.php receives the notification and processes the data obtained, and encrypts the data through the function _authcode in the function synlogin (located in uc.php) (default uses UC_KEY as the key), and uses the function _setcookie Set cookies.

6. Each application uses the corresponding key to decode the cookie set above and obtain the user ID and other data; use this value to determine whether the user has logged in through other applications, so that the user can log in automatically.

Logging.php in application ------>client.php in uc_client------>Ucenter------>api/ in other applications uc.php.

In fact, the principle of Ucenter to achieve synchronous login is cookie. After an application successfully logs in, it transfers data to Ucenter and lets Ucenter notify other applications to also set cookies, so that users can use the cookies that have been set when accessing other applications. Cookie enables automatic login.

General steps, first install ucenter and then copy the uc_client folder to your own project, and then configure several files

client.php is equivalent to the function library

uc.php is equivalent to the callback file

config.php is the configuration file


When you have two applications set up to synchronize login, when you log in to an application, then execute

include './config.inc.php';
include './uc_client/client.php';
$usernames=" kyee";
$passwords="123456";
list($uid, $username, $password, $email) = uc_user_login($usernames, $passwords );
if($uid > 0) {

setcookie("username",$username,time()+intval(24*3600));
echo uc_user_synlogin($uid);
echo 'Login successful';
} elseif($uid == -1) {
echo 'The user does not exist or has been deleted';
} elseif($uid == -2) {
echo 'wrong password';
} else {
echo 'undefined';
}


uc_user_synlogin() This function represents the synchronous login to all other functions that enable synchronous login. uc itself will loop through all the applications that enable synchronous login in the background and then output it on the page


JS code like this is sent to each application that enables synchronous login, and then the callback file uc.php of each application that enables synchronous login will be decrypted after receiving it. After decryption, you will actually You can write the code yourself. The code of this uc.php callback file does not have to be written in their format. You can also write your own code.


In fact, the principle of UC is very simple. After an application logs in, it then polls the callback file sent to the synchronously logged-in application in the background. After the callback file receives the user ID, it generates a cookie or session and then enters the login mode. .

Why does the UCenter user management center always display "communication failure" when adding daily group purchases and Note Dog Weibo? How to solve it? High score answer

Ucenter Communication Principle
wenku.baidu.com/...1.html

I am a second-year communication engineering major and teach unofficial answers. What is the purpose of learning communication principles? In what jobs would it work?

I am also a 2-book correspondent.
Studying communications in college is not only about choosing your own major, but also choosing your own career. Now that you have chosen it, you really have to study it with all your heart. Find a counterpart at work. If you are not interested now, you should cultivate your interest as soon as possible. Communication can be said to be a sunrise industry that will be lost forever, so as long as you learn it well, you don’t have to worry about not finding a good job!
There are many undergraduate courses, and each school is different. But there will definitely be some major basic courses. "Model Electricity", "Counting Points", "Signal System", "Principles of Communication". Especially signals, which are the theoretical basis of communication, must be learned well. In fact, to put it bluntly, it means learning mathematics well. No matter you want to take the postgraduate entrance examination or find a job in the future, you will definitely not suffer if you learn mathematics well. It is especially useful when taking postgraduate entrance examinations. Hey, let me express my feelings. There are many motivations for learning communications. First of all, if you work in the communications industry for more than 3 years, the salary is very high. What may seem profound to outsiders may appear to be very simple, which will give you a sense of accomplishment. The direct motivation is that you can go to large website forums such as Communication, or read introductory books such as "Dahua Communication".
Hope this information is useful to you.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/868763.htmlTechArticleucenter Communication Principle, ucenter 1. The user logs in to discuz, and uses the function uc_user_login in the logging.php file to post messages Verify the data, that is, verify the username and password...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template