textReply回复内容在微信端显示不完整

- 6 年 前

构造一个返回结果的函数,$results .='从网址:'.$url.'下载文件所需解压密码或提取码:'.$pass;
$url和$pass的值都有设置,然后在用$weixin_reply->textReply($results);返回给微信。当$pass值为字母的时候微信端回复对应的关键字可以获得"从网址:http://xxx.com下载文件所需解压密码或提取码:abcd"如果$pass值中含有数字或者中文,那么微信端获取的内容为从网址:http://xxx.com下载文件所需解压密码或提取码:"$pass部分不显示。
谁遇到过,求帮助

2条回复

- 6 年 前

这个是参照人品计算器写的扩展

function weixin_robot_download_reply($keyword){
	global $weixin_reply;

	$newkey = str_replace('tq', '', $keyword);
	$name = is_numeric($newkey)?$newkey:null;
	if(!$name){
		$weixin_reply->textReply('tq后面必须是带有数值格式的文章ID才可以得到您想要的内容。');
	}else{
		$results = weixin_robot_get_download_results($name);
		$weixin_reply->textReply($results);
	}
	$weixin_reply->set_response('download');
}

function weixin_robot_get_download_results($name){
	global $post;
	$content = get_post($name)->post_content;
	preg_match_all('/[downloads*urls="(.*)"]/isU',  $content, $matches);
	$down_content = array();
	if (!empty($matches['1'])) {
		foreach ($matches['1'] as $key=>$value) {
			$pass_array 	= 	check_str($value);
			foreach ($pass_array as $v) {
				if(isset($v['pass']) && !empty($v['pass'])){
					$down_content[$key] = array('url'=>$v['url'],'pass'=>$v['pass']);
				}
			}
		}
	}
	$results =	"";	
	if (!empty($down_content)) {
		foreach ($down_content as $value) {	
			$pass 	= 		$value['pass'];
			$url 	=		$value['url'];
			$results .='从网址:'.$url.'下载文件所需解压密码或提取码:'.$pass;
		}
	}else{
		$results .='在您所输入的文章ID中没有找到相关下载信息,请确认!!!';
	}
	return $results;
}
Denis | 邓鸿华
Denis | 邓鸿华 - 6 年 前

这个只能是你代码的问题,textReply 应该木有问题的,我多复杂的数据都传递过。

我要回复

暂时不支持网页回复,请安装