有没有想过发一个长链接给一个公众号,然后公众号给你一个简短的网址?其实很简单:FromUserName;$toUsername=$postObj->ToUserName;$MsgT=$postObj->MsgType;$时间=时间();//如果是用户发送的文本类型if($MsgT=="text"){$key=trim($postObj->Content);$textTpl="%s";$msgT类型=“文本”;//生成短网址$dwzapi="http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=".$key;$dwzpost=file_get_contents($dwzapi);$dwzjsondecode=json_decode($dwzpost,true);//发送$contentStr=$dwzjsondecode[0]['url_short'];$resultStr=sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$contentStr);回声$resultStr;出口;}else{$textTpl="%s";$米sgType="文本";//发送$contentStr="请发送链接";$resultStr=sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$contentStr);回声$resultStr;出口;}//如果用户发送的事件(event)类型if($MsgT=="event"){$Event=$postObj->Event;if($Event==subscribe){$contentStr="欢迎关注";}else{$contentStr="希望您下次注意,但是您不会收到这条信息";}$textTpl="%s";$标题e=$postObj->标题;$Description=$postObj->描述;$Url=$postObj->Url;$msgType='文本';$resultStr=sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$contentStr);回声$resultStr;出口;}}else{echo"不正确";出口;}}$echoStr=$_GET["echostr"];//如果有$echoStr,表示对接if(!empty($echoStr)){//对接规则$signature=$_GET["signature"];$timestamp=$_GET["时间戳"];$nonce=$_GET["nonce"];$令牌=令牌;$tmpArr=array($token,$timestamp,$nonce);排序($tmpArr,SORT_STRING);$tmpStr=内爆($tmpArr);$tmpStr=sha1($tmpStr);如果($tmpStr==$signature){echo$echoStr;}else{回声“”;出口;}}else{responseMsg();}?>配置方法:1.登录2.打开基础配置3.填写上面代码的urlToken,在代码中自己设置。对应的,EncodingAESKey是随机生成的。4.然后开启这个配置,去公众号发个url看看!经历:作者:TANKING网址:http://www.likeyunba.com/