uc.php interface debugging, Ucenter integration of the methods of docking their own systems and Authracation has expiried reasons

Source: Internet
Author: User
Tags php print

Special attention, integration, must enter DZ Forum background-----Webmaster----ucenter Settings, the activation settings, otherwise, you in the test to the forum to register and log in, may have been unsuccessful login. and couldn't find the reason.

One, about synchronizing from forum to your website.

Our system, such as dream system, if you want to receive membership information from other systems such as forums, and log in or register synchronously, you need to have an interface in our system.

This interface is the api/uc.php in the root directory of the system, and he is the core file that Ucenter communicates with our system.

If you want to debug, such as your system URL for www.123.com then, www.123.com/api/uc.php, this open, you can debug.

However, the uc.php file needs to comment out some information before the method is debugged.

uc.php, usually there is such a paragraph.

if (!defined (' In_uc ')) {error_reporting (0);
	@set_magic_quotes_runtime (0); Defined (' MAGIC_QUOTES_GPC ') | |

	Define (' MAGIC_QUOTES_GPC ', GET_MAGIC_QUOTES_GPC ());

	$_dcache = $get = $post = Array ();

	$code = @$_get[' code '];
	
	Parse_str (_authcode ($code, ' DECODE ', Uc_key), $get);
	if (MAGIC_QUOTES_GPC) {$get = _stripslashes ($get);
	$timestamp = time ();
	if ($timestamp-$get [' time '] > 3600) {exit (' authracation has expiried ');
	} if (empty ($get)) {exit (' Invalid Request ');

	} $action = $get [' Action ']; Require_once Uc_client_root. '
	/lib/xml.class.php ';

	$post = Xml_unserialize (file_get_contents (' php://input ')); if (In_array ($get [' action]], array (' Test ', ' DELETE user ', ' renameuser ', ' gettag ', ' synlogin ', ' synlogout ', ' updatepw ', ' Updatebadwords ', ' updatehosts ', ' Updateapps ', ' updateclient ', ' updatecredit ', ' getcreditsettings ', '
		Updatecreditsettings ')) {$uc _note = new Uc_note ();
	Exit ($uc _note-> $get [' Action '] ($get, $post));
	}else{exit (api_return_failed); }


With this section, the display cannot be debugged.

We can simplify it to the following, you can directly access UC for debugging. Note Back up the original file first

if (!defined (' In_uc ')) {
defined (' MAGIC_QUOTES_GPC ') | | define (' MAGIC_QUOTES_GPC ', GET_MAGIC_QUOTES_GPC ());
$DBModel = new Db_model ();
	$get = $post = Array ();
	$get [' UID ']=2;//UC server sends a GET request, the user ID
       $get [' username ']= ' 121212 ';//If this is the username
    $get [' email ']= ' 1@163.com '; E
	-Mail include_once discuz_root. ' /uc_client/lib/xml.class.php ';
	$post = Xml_unserialize (file_get_contents (' php://input '));
	 $uc _note = new Uc_note (); 
Remove the parameter. and $get[' action ' to any of the above. For example Test,deleteuser, then refresh uc.php can directly access api/uc.php to test, such as
		Echo $uc _note-> Synlogout ($get, $post);
       or Echo $uc _note->synlogin ($get, $post);
		Exit ();
} else {
	exit;
}

In addition, the code inside the uc.php, that is, after the recovery, the actual deployment, you may encounter a number of small errors.

if (!defined (' In_uc ')) {

This is the simplified code above you need to revert to the original.

}

, this error may occur when you actually test for specific login effects, Authracation has expiried

This is typically the case in this application where the api/uc.php does not have a get to the other application or the uc_client sent by the forum. You can view the other side of the application of the \uc_client\data\cache\apps.php This file. Open and look inside there are several applications. If only one application of the forum is available. Without your system corresponding to the application, then, even if the background prompts the communication to succeed. Still can't sync from forum to your website. The contents should be similar to that of the normal

<?php
$_cache[' apps ' = Array (
  1 => 
  Array (
    ' AppID ' => ' 1 '),//This is the Forum application. If this is the only one, you cannot log in synchronously.
    Type ' => ' discuzx ',
    ' name ' => ' discuz! Board ',
    ' url ' => ' http://www.discuz2.com ',
    ' IP ' => ',
    ' viewprourl ' => ', ' apifilename '
    = > ' uc.php ',
    ' charset ' => ', '
    dbcharset ' => ', ' synlogin ' => '
    1 ', ' recvnote ' => '
    1 ' ,
    ' Extra ' => false,
    ' tagtemplates ' => ', ' allowips ' => '
    ,
  ),
    2=> 
  Array ( c20/> ' AppID ' => ' 2 ',//Another application, here is your website application ID, in the UC background view
    ' type ' => ' other ',
    ' name ' => ' another application site ',
    ' url ' = > ' http://www.viq.com ',//Your website home address
    ' IP ' => ',
    ' viewprourl ' => ',
    ' apifilename ' => ' ', '
    charset ' => ', '
    dbcharset ' => ',
    ' synlogin ' => ' 1 ',//1 indicates that the automatic login function opens
    ' recvnote ' => ' 1 ',
    ' extra ' => false,
    ' tagtemplates ' => ', ' allowips ' => ',)
;

? >

If you have applications here and you can't sync your members to the local system, you can debug this.

1, first use the other side of the application test URL, such as your forum URL for the login test, if it is www.234.com, then,

First modify the forum directory, this file, \uc_client\client.php find the Uc_user_synlogin function, in return $return, add this sentence print_r ($return);

And then

Open it

Www.234567.com/member.php?mod=logging&action=login, open the above address directly, if open is blank. Right-right to view the source, you can see the return of the synchronization login code. The code might be like this.

<script type= "Text/javascript" src= "http://www.viq.com/api/uc.php?"
Time=1473493067&cfzxnemdwjnj1uqrqgart5bqumwcp38i5myk6g "
reload= "1" ></script>


Then find the src= "" inside the URL, directly open, you can see the contents of the uc.php hint

If there is no content. You can comment out the error_reporting (0) in the uc.php;

and add an output print function below this code, namely Print_r ($get); The effect is as follows

if (MAGIC_QUOTES_GPC) {
		 $get = _stripslashes ($get);
	}
Print_r ($get); exit;

Second, from your website application to UC and Discuz forum synchronization, how to test.

An easy way to do this is to create a test.php file in your root directory, where the content is

Username and password 121212 This is your registration. You can test the login problem directly. Use your domain name to run/test.php after the right key to see the source code, on the application test site, directly open, you can in the Forum/api/uc.php print results debugging

<?php
require_once (' root/config/uc.php '); This is the database connection configuration copied from Ucenter
 require_once ' uc_client/client.php ' //This site should be in the UC client
 
 list ($status _id, $uc _username, $uc _password, $uc _email) = Uc_user_login (121212,121212, 0);
		0, username login UC

		 if ($status _id>=1) {//successfully login to UC
               
                    echo $synlogin =uc_user_synlogin ($status _id);//Sync Login Other application
					// Var_dump (Uc_user_synlogin ($status _id)); exit;
					Print_r (Uc_user_synlogin ($status _id)); exit;
                    $this->jump (-1);//success, jump
					
     }
	 if ($status _id==-2) {
		 //echo ' UC password error, proposed modify ';
                    Print_r ( -2); exit;
				If the username does not exist in the IF ($status _id==-1) {//UC, insert UC and update ucid
				
			
                   print_r ( -1);
 
 
/* End of File index.php
////* Location:./index.php/*


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.