Home > Article > Backend Development > Project integration Discuz UCenter, integration discuzucenter_PHP tutorial
Although I personally dislike discuz very much, there is no way, the market is power, especially for friends who integrate the discuz forum, if you don’t want to use it If there are two systems, integrating UCenter is inevitable. Although it is boring, it has to be done.
1. Preparation
1. Read the full text of uc api manual. Refer to http://faq.comsenz.com/library/UCenter/introduction/introduction_list.htm
2. Add application instructions in the uc background. Refer to http://faq.comsenz.com/viewnews-506 (official) http://wenku.baidu.com/view/3790fdd7195f312b3169a588.html (grassroots)
3. uc client necessary code, Download here
2. Example
Although it seems that the above preparations are enough, experience tells us, no, it is not enough. Disuzuz is not something that is just plain water, such as zend frame, dedecms, and ci. Without a bit of research spirit and a tossing temperament, it is impossible to understand its profound connotation, let alone control it. To achieve success, we need detailed explanatory text and necessary pictures, although you may not be successful with these.
Let’s take a look at my project structure first
tanahk is the real project address, x3.2 is my discuz forum file, open it
You can see that discuz x3.2 has been integrated with ucenter, where uc_server is the server, uc_client is the client, and the uc_client folder is in discuz x, discuz home, discuz xspace All other products are already bundled. But it has not been added to my tanahk project. According to the previous reference information, it must exist in every project. Therefore, we copy the client in developguide.zip under the preparation point 3 to below tanahk. And named it api
Because the UCenter application defaults to finding the api/uc.php file, the client folder must be renamed api. Go back to the developguide.zip compressed package, open the api/uc.php below, and copy it to tanahk/api.
tanahk’s directory structure changes to
Okay, now we can add our project application in the UCenter background . The background of uc is generally http://www.xxx.com/x3.2/uc_server/admin.php
Select "Application Management"--"Add New Application ”
Refer to 2 in the preparation above.
Application type: Other
Communication key: Find the key in discuz root/config/confgi_ucenter.php, define('UC_KEY', '...124sdf45s4d5fsd4f5s4...');discuz root is your uc directory.
Physical path of the application: can be empty, as long as the application main url is filled in correctly
Application interface file name: keep uc.php, no need to fill in api/uc.php
Whether to enable synchronous login: Yes, this is The key point is that in the future, multiple projects can share one uc, and there is no need to create a new user system by yourself.
Submit.
ecshop discuz ucenter integration
1. Install ucenter
2. Install discuz. It is integrated with ucenter during the installation process and does not require me to do anything
3. Install ecshop and uc_client Copy to the root directory (uc_client in the ucenter installation file). Then copy the configuration to data /config.php
define('UC_CONNECT', 'mysql');
define('UC_DBHOST', 'localhost ');
define('UC_DBUSER', 'root');
define('UC_DBPW', 'root');
define('UC_DBNAME', 'ucenter');
define( 'UC_DBCHARSET', 'utf8');
define('UC_DBTABLEPRE', '`ucenter`.uc_');
define('UC_DBCONNECT', '0');
define('UC_KEY', '1234567890');
define('UC_API', 'localhost/ucenter/upload');
define('UC_CHARSET', 'utf-8');
define('UC_IP', '127.0 .0.1');
define('UC_APPID', '3');
define('UC_PPP', '20');
The communication was found to be successful in the ucenter background. Then install ucenter in ecshop. After installation, check whether the settings are consistent with those in ucenter. It should be fine. Now my discuz and ecshop can log in simultaneously.
168 is installed. Install ucenter and go to ucenter to add applications
(1). Enter the UC management background, click 'Application Management', then click 'Add New Application', and then select 'Customize' Install'
Application name: Enter PHP168 whole site system
Application URL: Enter http://website domain name/do (no / is required at the end, and note that it ends with do)
Application IP: Leave it blank Just
Communication key: write any one, such as 123abcdkjhh
Application type: select 'Other
Physical path of application: leave it blank
View profile page address: leave it blank
Application interface file name: uc.php
Tag single display template: Leave it blank
Tag template mark description: Leave it blank
Whether to enable synchronous login: select 'Yes'
No Accept the notification: Select 'Yes'
Finally submit. After submission, return to the application list. Then select the application you just submitted and click Edit.
Copy the code in 'Application UCenter Configuration Information:' , just put it in the second line of the entire site/do/config.php.
Then integrate discuz and home through ucenter