当前位置:Gxlcms > PHP教程 > 请问一下在微信子自定义菜单中的url链接

请问一下在微信子自定义菜单中的url链接

时间:2021-07-01 10:21:17 帮助过:34人阅读

我基于原有的微信平台CMS做了一个功能,然后把功能的链接放到菜单中,通过点击菜单进入页面。但是一开始可以顺利进入,还点了几次异步上传照片,但是会显示error openid:{wechat_id}错误提示。可是后来就不行了,进不了页面,一点就是在一个空白页面显示error openid:{wechat_id},在windows的微信开发者工具又显示no token ,后来又不知道怎么老是跳成手机端首页。恳求高手帮帮忙。


回复讨论(解决方案)

这些错误提示时你们自己代码写的吧,你要把对应代码发出来

这些错误提示时你们自己代码写的吧,你要把对应代码发出来



_appid = C("appid");		$this->_secret = C("secret");		$this->time = 0;		$this->token = $this->_get("token");		if (ALI_FUWU_GROUP && (date("Y") == 2015)) {			$fuwuuserlist = M("fuwuuser")->where(array("token" => $this->token))->select();			foreach ($fuwuuserlist as $fuwuvo ) {				$fuwuuserinfo = M("userinfo")->where(array("token" => $this->token, "wecha_id" => $fuwuvo["wecha_id"]))->find();				if ($fuwuuserinfo == "") {					if ($fuwuvo["gender"] == "M") {						$fuwuvo["gender"] = 1;					}					else if ($fuwuvo["gender"] == "F") {						$fuwuvo["gender"] = 2;					}					else {						$fuwuvo["gender"] = 0;					}					$add_userinfo_hb = array("token" => $this->token, "wecha_id" => $fuwuvo["wecha_id"], "issub" => 1, "portrait" => $fuwuvo["avatar"], "truename" => $fuwuvo["real_name"], "nickname" => $fuwuvo["real_name"], "wechaname" => $fuwuvo["real_name"], "sex" => $fuwuvo["gender"]);					$add_userinfo_hb = array_map("nulltoblank", $add_userinfo_hb);					$id_userinfo = M("userinfo")->add($add_userinfo_hb);				}				else {					if (($fuwuuserinfo["portrait"] == "") || ($fuwuuserinfo["wechaname"] == "")) {						if ($fuwuvo["gender"] == "M") {							$fuwuvo["gender"] = 1;						}						else if ($fuwuvo["gender"] == "F") {							$fuwuvo["gender"] = 2;						}						else {							$fuwuvo["gender"] = 0;						}						$save_userinfo_hb = array("token" => $this->token, "wecha_id" => $fuwuvo["wecha_id"], "issub" => 1, "portrait" => $fuwuvo["avatar"], "truename" => $fuwuvo["real_name"], "nickname" => $fuwuvo["real_name"], "wechaname" => $fuwuvo["real_name"], "sex" => $fuwuvo["gender"]);						$save_userinfo_hb = array_map("nulltoblank", $save_userinfo_hb);						$up_userinfo = M("userinfo")->where(array("token" => $this->token, "wecha_id" => $fuwuvo["wecha_id"]))->save($save_userinfo_hb);					}				}			}		}		if (strlen($this->token)) {			$_SESSION["wap_token"] = $this->token;		}		if (!$this->token) {			$this->token = $_SESSION["wap_token"];		}		if (!empty($_SESSION["wap_token"])) {			$this->token = $_SESSION["wap_token"];		}		if (!$this->token && !strpos(MODULE_NAME, "Drp") === false) {			$id = $this->_get("id");			if ($id) {				$did = M("Distributor_store")->where(array("id" => $id))->getField("did");				$this->token = M("Distributor")->where(array("id" => $did))->getField("token");			}		}		$this->assign("token", $this->token);		if (!$this->token) {			exit("no token");		}		if ($this->token && !preg_match("/^[0-9a-zA-Z]{3,42}$/", $this->token)) {			exit("error token");		}		$this->wxuser = S("wxuser_" . $this->token);		if (!$this->wxuser || 1) {			$this->wxuser = D("Wxuser")->where(array("token" => $this->token))->find();			S("wxuser_" . $this->token, $this->wxuser);		}		$this->owxuser = $this->wxuser;		$this->assign("wxuser", $this->wxuser);		$this->_checkVipTime($this->wxuser);		$fake = 0;		if (($this->wxuser["winxintype"] != 3) && $this->_appid && $this->_secret) {			if ($this->wxuser["oauth"] == 1) {				if (!$this->isAgent) {					$this->wxuser["appid"] = trim($this->_appid);					$this->wxuser["appsecret"] = trim($this->_secret);				}				else {					$this->wxuser["appid"] = $this->thisAgent["appid"];					$this->wxuser["appsecret"] = $this->thisAgent["appsecret"];				}			}			$fake = 1;		}		$toAuth = 0;		if ((C("server_topdomain") == "paiyi.net.cn") && (C("site_url") != "http://weixintest.paiyi.net.cn")) {			$toAuth = 1;		}		else {			$toAuth = $this->wxuser["oauth"];		}		if ((C("server_topdomain") == "pigcms.cn") && ($this->wxuser["winxintype"] != 3)) {			$this->wxuser["appid"] = $this->_appid;			$this->wxuser["appsecret"] = $this->_secret;			$this->wxuser["oauth"] = 0;			$this->wxuser["is_domain"] = 1;			$fake = 1;		}		$wexintype = $this->wxuser["winxintype"];		$session_openid_name = "token_openid_" . $this->token;		$session_fakeopenid_name = "token_fakeopenid_" . $this->token;		$session_reopenid_name = "token_reopenid_" . $this->token;		$session_oauthed_name = "token_oauthed_" . $this->token;		$getUserInfoModules = getUserInfoModule::index();		$getUserinfo = 0;		if (isset($_GET["rget"]) || intval($_GET["ali"])) {			$_SESSION["otherSource"] = 1;			$toAuth = 0;			$this->wxuser["oauthinfo"] = 0;		}		if (isset($_SESSION["otherSource"])) {			$toAuth = 0;		}		if ($this->wxuser["oauthinfo"] && !$_SESSION[$session_oauthed_name]) {			if ($_SESSION[$session_openid_name]) {				$fansInfo = M("Userinfo")->where(array("token" => $this->token, "wecha_id" => $_SESSION[$session_openid_name]))->find();				if ($toAuth) {					if (!$fansInfo || !$fansInfo["wechaname"] || !$fansInfo["portrait"]) {						unset($_SESSION[$session_openid_name]);						$getUserinfo = 1;					}				}			}			else {				if (isset($_SESSION[$session_reopenid_name]) && $_SESSION[$session_reopenid_name]) {					$fansInfo = M("Userinfo")->where(array("token" => $this->token, "wecha_id" => $_SESSION[$session_reopenid_name]))->find();					if (!$fansInfo || !$fansInfo["wechaname"] || !$fansInfo["portrait"]) {						unset($_SESSION[$session_openid_name]);						unset($_SESSION[$session_reopenid_name]);						$getUserinfo = 1;					}				}				else {					$getUserinfo = 1;				}			}		}		$this->isFuwu = 0;		$this->isWechat = 0;		$userAgent = strtolower($_SERVER["HTTP_USER_AGENT"]);		if (strpos($userAgent, "alipayclient")) {			$this->isFuwu = 1;		}		else if (strpos($userAgent, "micromessenger")) {			$this->isWechat = 1;		}		if (!M("Weixin_account")->where(array("type" => 1))->find()) {			M("Wxuser")->where("1")->save(array("type" => 0));		}		$this->cookieToSession();		if ($_GET["wecha_id"] && ($_GET["wecha_id"] != $_SESSION[$session_openid_name]) && (3 != $wexintype)) {			unset($_SESSION[$session_openid_name]);			unset($_SESSION[$session_oauthed_name]);			cookie("oauth2_" . $this->token, NULL);		}		if ($this->isFuwu) {			if ($_GET["wecha_id"] != "") {				$this->wecha_id = $_GET["wecha_id"];			}			else {				$this->wecha_id = session("wecha_id");			}			session("wecha_id", $this->wecha_id);			$thisfuwuuser = M("fuwuuser")->where(array("token" => $this->token, "wecha_id" => $this->wecha_id))->find();			$isFuwuoauth = session("isFuwuoauth");		}		if ($this->isFuwu && ($isFuwuoauth != "yes")) {			$fw_wecha_id = FuwuOAuth::index($this->token);			if ($fw_wecha_id != "no") {				$this->wecha_id = $fw_wecha_id;				session("wecha_id", $this->wecha_id);				session("isFuwuoauth", "yes");			}			else if ($this->wecha_id == "") {				$this->error("服务窗没有获取粉丝信息权限
请在服务窗开发者中确认开通"); exit(); } $_SESSION[$session_openid_name] = $this->wecha_id; $_SESSION[$session_oauthed_name] = 1; } $users = M("Users")->where(array("id" => $this->wxuser["uid"]))->find(); if (("payReturn" == ACTION_NAME) && (0 < $users["is_syn"])) { $_SESSION[$session_openid_name] = $_GET["wecha_id"]; }

if (empty($_SESSION[$session_openid_name]) && (0 < $users["is_syn"])) {			$_SESSION["auth_callback_" . $this->token] = array("url" => getSelfUrl(array("wecha_id")), "token" => $this->token);			$url = $users["source_domain"] . A("Home/Auth")->getCallbackUrl($users["is_syn"], "auth") . "token=" . $this->token . "&source=pigcms";			header("Location:" . $url);			exit();		}		if (2 == $users["is_syn"]) {			$url = $users["source_domain"] . A("Home/Auth")->getCallbackUrl($users["is_syn"], "follow") . "wecha_id=" . $_SESSION[$session_openid_name];			$this->_auth = json_decode(HttpClient::getInstance()->get($url));			if (1 == $this->_auth->code) {				M("Userinfo")->where(array("token" => $this->token, "wecha_id" => $_SESSION[$session_openid_name]))->setField("issub", 1);			}			else {				M("Home")->where(array("token" => $this->token))->setField("gzhurl", $this->_auth->follow->url);				$this->wxuser["qr"] = $this->_auth->follow->qrcode;				$this->wxuser["wxname"] = $this->_auth->follow->wechat;			}		}		if (!isset($_SESSION[$session_openid_name]) || !$_SESSION[$session_openid_name]) {			if ($this->isFuwu) {			}			else {				$apiOauth = new apiOauth();				if ((!$_GET["wecha_id"] || (urldecode($_GET["wecha_id"]) == "{wechat_id}")) && ($_GET["wecha_id"] != "no") && $this->wxuser["appid"] && ((($this->wxuser["type"] == 0) && ($this->wxuser["appsecret"] != "")) || ($this->wxuser["type"] == 1)) && ($toAuth == 1)) {					$token_info = $apiOauth->webOauth($this->wxuser, "", $fansInfo);				}				if (!empty($token_info)) {					$this->wecha_id = $token_info["openid"];					if (3 == $wexintype) {						$fake = 0;					}					if ($fake) {						if (isset($_SESSION[$session_fakeopenid_name])) {							$datainfo["issub"] = 1;							$this->wecha_id = $_SESSION[$session_fakeopenid_name];							$userinfoModel = M("Userinfo");							$userinfoData = $userinfoModel->where(array("token" => $this->token, "wecha_id" => $_SESSION[$session_fakeopenid_name]))->find();							if ($userinfoData) {								$fakeUserinfoData = $userinfoModel->where(array("token" => $this->token, "wecha_id" => $token_info["openid"], "fakeopenid" => $token_info["openid"]))->find();								if ($fakeUserinfoData) {									if ($userinfoModel->where(array("id" => $fakeUserinfoData["id"]))->save($this->_mergeUserinfo($userinfoData, $fakeUserinfoData))) {										$userinfoModel->where(array("id" => $userinfoData["id"]))->delete();									}								}								else {									$userinfoModel->where(array("id" => $userinfoData["id"]))->setField("fakeopenid", $token_info["openid"]);								}							}							else {								$fakeUserinfoData = $userinfoModel->where(array("token" => $this->token, "wecha_id" => $token_info["openid"], "fakeopenid" => $token_info["openid"]))->find();								if ($fakeUserinfoData) {									$userinfoModel->where(array("id" => $fakeUserinfoData["id"]))->setField("wecha_id", $_SESSION[$session_fakeopenid_name]);								}							}							$this->wecha_id = $_SESSION[$session_fakeopenid_name];						}						else {							$fansInfo = M("Userinfo")->where(array("token" => $this->token, "fakeopenid" => $token_info["openid"]))->find();							if ($fansInfo) {								$this->wecha_id = $fansInfo["wecha_id"];							}						}					}					if ($this->wxuser["oauthinfo"] && (MODULE_NAME != "Index")) {						$jsonui = $apiOauth->get_fans_info($token_info["access_token"], $token_info["openid"]);						if (isset($jsonui["openid"]) && $jsonui["openid"]) {							if ($fansInfo) {								$exist = $fansInfo["id"];								$issub = $fansInfo["issub"];							}							else {								$existInfo = M("Userinfo")->where(array("token" => $this->token, "wecha_id" => $this->wecha_id))->find();								$issub = $existInfo["issub"];								$exist = $existInfo["id"];							}							$datainfo["wechaname"] = str_replace(array("'", "\\"), array(""), $jsonui["nickname"]);							$datainfo["sex"] = $jsonui["sex"];							$datainfo["portrait"] = $jsonui["headimgurl"];							$datainfo["token"] = $this->token;							$datainfo["wecha_id"] = $jsonui["openid"];							$datainfo["city"] = $jsonui["city"];							$datainfo["province"] = $jsonui["province"];							$datainfo["truename"] = $datainfo["wechaname"];							$datainfo["wecha_id"] = $this->wecha_id;							if ($fake) {								$datainfo["fakeopenid"] = $jsonui["openid"];							}							if (3 == $wexintype) {								$datainfo["fakeopenid"] = "";								$datainfo["issub"] = $this->_issubService($datainfo["wecha_id"]);							}							if ($exist) {								D("Userinfo")->where(array("id" => $exist))->save($datainfo);							}							else {								D("Userinfo")->add($datainfo);							}						}						else {							$this->error("授权不对哦,请重置您的appsecret!
" . $this->wxuser["appid"] . "
" . $this->wxuser["appsecret"] . "
" . $jsonui["errcode"], "#"); exit(); } } if (empty($this->wxuser["oauthinfo"]) && (MODULE_NAME != "Index")) { if ($fansInfo) { $exist = $fansInfo["id"]; } else { $existInfo = M("Userinfo")->where(array("token" => $this->token, "wecha_id" => $this->wecha_id))->find(); $exist = $existInfo["id"]; } $datainfo["token"] = $this->token; $datainfo["wecha_id"] = $this->wecha_id; if ($fake) { $datainfo["fakeopenid"] = $token_info["openid"]; } if (3 == $wexintype) { $datainfo["fakeopenid"] = ""; $datainfo["issub"] = $this->_issubService($datainfo["wecha_id"]); } if ($exist) { D("Userinfo")->where(array("id" => $exist))->save($datainfo); } else { D("Userinfo")->add($datainfo); } } $_SESSION[$session_openid_name] = $this->wecha_id; $_SESSION[$session_oauthed_name] = 1; cookie("oauth2_" . $this->token, array("wap_token" => $this->token, "wecha_id" => $this->wecha_id, "appid" => $this->wxuser["appid"]), 311040000); } else { $this->wecha_id = $this->_get("wecha_id"); if ($fake && $toAuth && !isset($_GET["isappinstalled"])) { $_SESSION[$session_fakeopenid_name] = $this->wecha_id; } if (!$toAuth) { $_SESSION[$session_openid_name] = $this->wecha_id; } if (isset($_GET["wecha_id"]) && strlen($_GET["wecha_id"]) && $toAuth) { $get_parms = $_GET; unset($get_parms["wecha_id"]); $get_parm_str = ""; if ($get_parms) { $comma = ""; foreach ($get_parms as $gpk => $gpv ) { $get_parm_str .= $comma . $gpk . "=" . $gpv; $comma = "&"; } } $get_parm_str .= "&g=" . GROUP_NAME . "&m=" . MODULE_NAME . "&a=" . ACTION_NAME; $_SESSION[$session_reopenid_name] = $this->wecha_id; header("Location:" . $this->siteUrl . "/index.php?" . $get_parm_str); exit(); } } } } else { $this->wecha_id = $_SESSION[$session_openid_name]; } if ($_GET["yundabao"] == 1) { cookie("yundabao", "1", 31536000); } $yundabao = cookie("yundabao"); if ($yundabao != "1") { if ($this->wecha_id && !preg_match("/^[0-9a-zA-Z_\-\s]{3,82}$/", $this->wecha_id)) { exit("error openid:" . $this->wecha_id); } }



它就是有时输出 error openid:" 这一行的东西,有时又输出 no token ,然后不知道怎么有时又跳回首页,

人气教程排行