ecshop与Ucenter通讯失败的一个很怪的问题

来源:互联网 发布:网络负面新闻消除方案 编辑:程序博客网 时间:2024/06/06 18:23

首先上一篇好文 http://blog.csdn.net/viqecel/article/details/52485774


       注意,uc.PHP接口如何调试,(api/uc.php的作用是把论坛等其它应用,传送过来的用户名等信息,向自己的系统中同步登录,或同步注册会员),查看这里的教程.http://blog.csdn.net/viqecel/article/details/52492081


      ucenter 提示通信失败,是因为在\uc_server\control\admin\app.php  这个函数中,function onping()  返回的值不是1.

在大约132有这么一句

    } else {                  //echo $url;exit();                  echo 'document.getElementById(\'status_'.$appid.'\').innerHTML = "<img src=\'images/error.gif\' border=\'0\' class=\'statimg\' \/><span class=\'red\'>'.$this->lang['app_connent_false'].'</span>";testlink();';              }  


       我们可以在else{ 的后面增加echo $url;exit();然后想办法查看.他返回的网址是多少.

怎么看呢.可以用谷歌浏览器,进后台uc后台应用管理后,点击键盘上的f12,进入谷歌调试模式.然后.点击左下角的小箭头,如下图一,点击一下 通信失败 这四个字.看下他对应的网址是多少.

如图



        然后,下图,注意红框中的关键点,找到 源码代码中的 通信失败或通信成功 四个字,他的下面,即对应的script里面的网址,右键,复制网址,在浏览器中打开.即可返回我们要的内容.






         假如他返回的网址是http://www.viq.com/api/uc.php?code=612122

则直接打开这个网址,看下他返回什么信息.如果404,则这个文件不存在,所以通信失败.如果是空白内容,则找一下api/uc.php这个文件,把开头的error_reporting(0); 这一句注释掉,看一下这个文件是不是有什么报错.解决好php或sql错误后,再把error_reporting(0);前面的注释去掉.

然后,\uc_server\control\admin\app.php 把这个文件的echo $url;exit();这一句注释掉,重新打开上面,右键复制的那个网址,看下返回的是不是1,如果返回的是1,则应用管理列表中,会显示通信成功.

当然前提是你有uc.php这个通信接口,并且接口中有一个test函数.具体看官方demo吧.

function test($get, $post) {return API_RETURN_SUCCEED;}

---------------------------------------------------------------------------------------------------------------

我根据上面的方法找url,访问之后报错,错误信息如下

Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 2641

然后找到cls_mysql.php

  if (defined('DEBUG_MODE') && (DEBUG_MODE & 8) == 8)        {            $logfilename = $this->root_path . DATA_DIR . '/mysql_query_' . $this->dbhash . '_' . date('Y_m_d') . '.log';            $str = $sql . "\n\n";            if (PHP_VERSION >= '5.0')            {                file_put_contents($logfilename, $str, FILE_APPEND);            }            else            {                $fp = @fopen($logfilename, 'ab+');                if ($fp)                {                    fwrite($fp, $str);                    fclose($fp);                }            }        }

在init.php中都已经定义了DATA_DIR常量,但是缺说没定义,无解

/* 创建 ECSHOP 对象 */$ecs = new ECS($db_name, $prefix);define('DATA_DIR', $ecs->data_dir());define('IMAGE_DIR', $ecs->image_dir());


最后在data/config中把DEBUG_MODE改成不包含8的就行了

define('DEBUG_MODE', 7);//修改调试模式

2017/7/8 深圳