Weiphp后台群发推送微信公众号文章插件【基础/单篇推送】
发布时间:2017-11-02, 15:05:22 分类:PHP | 编辑 off 网址 | 辅助
图集1/7
正文 3413字数 2,022,734阅读
安装插件
在后台安装插件

在后台安装插件
添加模型字段

模型标识
模型名称
列表定义
字段

模型标识
qunsend
Run code
Cut to clipboard
模型名称
群发推送
Run code
Cut to clipboard
列表定义
id:ID
title:标题
ctime|time_format:预览时间
qf:当前
id|get_name_by_status_qunfasyl:群发预览
id|get_name_by_status_qunfas:群发推送
Run code
Cut to clipboard
字段
字段 | 名称 | 数据类型 | 是否显示 | 是否必填 |
---|---|---|---|---|
coverurl | 封面图片url | 字符串 | 不显示 | 否 |
content | 图文消息页面的内容 | 编辑器 | 不显示 | 否 |
sid | 推送文章id | 数字 | 不显示 | 否 |
media_id | media_id | 字符串 | 不显示 | 否 |
title | 标题 | 字符串 | 始终显示 | 否 |
ctime | 时间 | 时间 | 始终显示 | 否 |
qf | 状态 | 字符串 | 始终显示 | 否 |
图文回复
列表定义 添加
列表定义 添加
id|get_name_by_status_scqf:推送群发
Run code
Cut to clipboard
添加全局函数
\Application\Common\Common\function.php
Run code
Cut to clipboard
//start
// 以POST方式提交数据
function post_data($url, $param, $is_file = false, $return_array = true) {
if (! $is_file && is_array ( $param )) {
$param = JSON ( $param );
}
if ($is_file) {
$header [] = "content-type: multipart/form-data; charset=UTF-8";
} else {
$header [] = "content-type: application/json; charset=UTF-8";
}
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_SAFE_UPLOAD, false);
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $header );
curl_setopt ( $ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)' );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $ch, CURLOPT_AUTOREFERER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $param );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
$res = curl_exec ( $ch );
$flat = curl_errno ( $ch );
if ($flat) {
$data = curl_error ( $ch );
addWeixinLog ( $flat, 'post_data flat' );
addWeixinLog ( $data, 'post_data msg' );
}
curl_close ( $ch );
$return_array && $res = json_decode ( $res, true );
return $res;
}
//生成群发文章
function get_name_by_status_scqf($val){
return '<a href="/index.php?s=/addon/Qunsend/Qunsend/sf/id/'.$val.'">生成</a>';
}
//群发推送
function get_name_by_status_qunfas($val, $name, $model_id) {
//$newwwtt=date('YmdH',time());
//$mm=md5('iswtf.com99'.$val.$newwwtt); /mm/'.$mm.'
return '<a href="/index.php?s=/addon/Qunsend/Qunsend/qunfas/id/'.$val.'">推送</a>';
}
//群发预览
function get_name_by_status_qunfasyl($val, $name, $model_id) {
//$newwwtt=date('YmdH',time());
//$mm=md5('iswtf.com99'.$val.$newwwtt); /mm/'.$mm.'
return '<a href="/index.php?s=/addon/Qunsend/Qunsend/qunfasyl/id/'.$val.'">预览 </a>';
}
//end
Run code
Cut to clipboard
微网站设置
添加设置配置修改文件
添加设置配置修改文件
\Addons\WeiSite\config.php
Run code
Cut to clipboard
,
'bbyueyuesjttsyywxh' => array (
'title' => '群发推送管理员预览微信号:',
'type' => 'text',
'value' => '',
'tip' => ''
),
'wxfmzdddd'=>array(
'title'=>'群发推送文图片封面:',
'type'=>'radio', //表单的类型:text、textarea、checkbox、radio、select等
'options'=>array( //select 和radion、checkbox的子选项
'1'=>'完整显示(上下/左右有空白)', //值=>文字
'0'=>'默认拉伸剪切(图片显示不完全)',
),
'value'=>'0', //表单的默认值
'tip'=>'建议尺寸900x500'
)
Run code
Cut to clipboard
在网站根目录放置图片
没有封面图片时默认显示此图片
完整显示封面模式背景图片(右键保存↓图片)

↑保存文件名
新合成封面图片将保存在网站根目录 12345678980.jpg 再上传至微信服务器
weiphp微信多客服系统插件
没有封面图片时默认显示此图片
logo.png
Run code
Cut to clipboard
完整显示封面模式背景图片(右键保存↓图片)
↑保存文件名
a.png
Run code
Cut to clipboard
新合成封面图片将保存在网站根目录 12345678980.jpg 再上传至微信服务器
weiphp微信多客服系统插件
(支付宝)给作者钱财以资鼓励 (微信)→
有过 14 条评论 »
图文消息,一个图文消息支持1到8条图文
QunsendController.class.php
<?php namespace Addons\Qunsend\Controller; use Home\Controller\AddonsController; class QunsendController extends AddonsController{ function sf(){ $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); } function nconfig(){ return getAddonConfig ( 'WeiSite' ); } //预览 function qunfasyl(){ $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $nconfig=$this->nconfig(); //echo $nconfig['bbyueyuesjttsyywxh'];exit; $access_token=get_access_token (); $s=M('qunsend')->where('id='.$id)->find(); $media_id=$s['media_id']; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"'.$nconfig['bbyueyuesjttsyywxh'].'","mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); //dump($res['0']); if($res['0']!=0){ echo $res['errmsg']; exit; } $sav['qf']='已预览'; M('qunsend')->where('id='.$id)->save($sav); $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); //if($res['0']==0) echo '预览已经发送'; exit; } //推送 function qunfas(){ //exit; $id=I('get.id')+0; if(!$id){ echo 'no id'; exit; } $access_token=get_access_token (); $s=M('qunsend')->where('id='.$id)->find(); $media_id=$s['media_id']; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=' . $access_token; $paramStr .= '{"filter":{"is_to_all":true},"mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews","send_ignore_reprint":0}'; $res = post_data ( $url, $paramStr ); if($res['0']!=0){ echo $res['errmsg']; exit; } $sav['qf']='已经群发'; M('qunsend')->where('id='.$id)->save($sav); $this->assign('id',$id); $this->assign('nconfig',$this->nconfig()); $this->display(); //dump($res); exit; } //多个推送 function morepostgetss($s,$access_token,$contenttop,$contentbottom,$id){ foreach($s as $k=>$a){ //封面上传 if(!$a['cover']){ $path='/logo2.jpg';} else{ $path = get_cover ( $a['cover'] ); $path = $path['path']; $res=$this->wximgup($path,$access_token); $coverurl=$res['media_id']; } //内容图片 $content=$a['content']; $content=str_ireplace("data-src=","src=",$content); preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match); foreach($match['1'] as $k=>&$v){ $res=$this->wximgup($v,$access_token,1); $content=str_ireplace($v,$res['url'],$content); } $nconfig=$this->nconfig(); $jsonArr['articles'][]=array( // 我就是少了这层array 才会报empty news data 错误 "title"=> $a['ntitle'],//标题 "thumb_media_id"=> $coverurl, "author"=>$nconfig['bbyueyuesjttsyywxh'],//发布者 "digest"=> $a['intro'],//简介 "show_cover_pic"=> 1,//是否显示封面? "content"=> $contenttop.$content.$contentbottom, "content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html'//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html', ); } $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; //dump($jsonArr['articles']);exit; $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=post_data ( $articlesurl, $json3, true ); $media_id=$res['media_id']; //dump($res);exit; $acs['sid']=$s['0']['id']; $acs['title']=$s['0']['ntitle']; $acs['ctime']=time(); $acs['media_id']=$media_id; $acs['content']=$s['0']['content']; $acs['coverurl']=$jsonArr['articles']['0']['thumb_media_id']; $cs=M('qunsend')->add($acs); echo $cs; exit; /* 预览 $nconfig=$this->nconfig(); $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"'.$nconfig['bbyueyuesjttsyywxh'].'","mpnews":{"media_id":"'.$media_id.'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); dump($res);exit;*/ } function ass(){ //获取推送文章 qunsend $id=I('get.id'); if(!$id){ echo 'no id'; exit; } $access_token=get_access_token (); $contenttop='<p><img src="http://mmbiz.qpic.cn/mmbiz_gif/qbke2mSU58VnW25BcMnoDRqJUNULibduT7b7bBLnWcvxgWCgzpg17QRKcz8icj7vrCoHG9a6gfiabuZuOl5oeluBw/0"></p>'; $contentbottom='<p><img src="http://mmbiz.qpic.cn/mmbiz_gif/qbke2mSU58VnW25BcMnoDRqJUNULibduT6EiaeRoqKTA8ObByU69qNMnBibqYkjeWtThD1dUm8vAwoGuHlm6JsiaOA/0"></p>'; /*$p='\618-150429120J5.gif'; $res=$this->wximgup($p,$access_token,1); dump($res); exit;*/ //是否多个群发 $inid=explode(',',$id); if($inid['1']){ //多个群发 $wc['id']=array('in','0,'.$id); $s=M('custom_reply_news')->where($wc)->select(); $this->morepostgetss($s,$access_token,$contenttop,$contentbottom,$inid['0']); return false; }else{ $s=M('custom_reply_news')->where('id='.$id)->find(); } $s['title']=$s['ntitle']; //dump($s);exit; $content=$s['content']; preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match); /*dump($match); exit;*/ //重新上传文中的图片链接 //$nimgurl=explode('<img src="',$s['content']); foreach($match['1'] as $k=>&$v){ $res=$this->wximgup($v,$access_token,1); $content=str_ireplace($v,$res['url'],$content); } /*dump($content); exit;*/ //$content=$s['content']; //$content=21321321;//str_ireplace('/Uploads/Editor/gh_c7d5c953c490/','http://ihosuwx.test2.resonance.net.cn/Uploads/Editor/gh_c7d5c953c490/',$content); //检查是否存在预推送文章 /*$cs=M('qunsend')->where('sid='.$id)->find(); if(empty($cs)){ }else{ exit; } //防止文章修改推送 改为使用最新 所以每次添加 */ if(!$s['cover']) $path='/logo.png'; else{ $path = get_cover ( $s['cover'] ); $path = $path['path']; } $nconfig=$this->nconfig(); //900*500比例尺寸 2017.10.10 if($nconfig['wxfmzdddd']){ $this->getnewjjfm($path); $path='/12345678980.jpg'; } //end //修复空封面bug $res=$this->wximgup($path,$access_token); //dump($res); //exit; $coverurl=$res['media_id']; //$content=$nimgurl;//$s['content']; //echo $content;exit; $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; $jsonArr = array( "articles"=> array( array( // 我就是少了这层array 才会报empty news data 错误 "title"=> $s['title'], "thumb_media_id"=> $coverurl, "author"=> $nconfig['bbyueyuesjttsyywxh'], "digest"=> $s['intro'], "show_cover_pic"=> 0, "content"=> $contenttop.$content.$contentbottom, "content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html',//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html', ) ) ); $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=post_data ( $articlesurl, $json3, true ); $media_id=$res['media_id']; /*$url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; $paramStr .= '{"towxname":"iswtf_","mpnews":{"media_id":"'.$res['media_id'].'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr );*/ //dump($res);exit; $acs['sid']=$id; $acs['title']=$s['title']; $acs['ctime']=time(); $acs['media_id']=$media_id; $acs['content']=$content; $acs['coverurl']=$coverurl; $cs=M('qunsend')->add($acs); echo $cs; //dump($acs); exit; //echo 'fasd'; $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . $access_token; //$paramStr .= '{"filter":{"is_to_all":true},'; //$paramStr .= '"text":{"content":"' . '3432423423' . '"},"msgtype":"text"}'; $res=$this->get_image_media_id(740,$access_token); $paramStr .= '{"towxname":"iswtf_","mpnews":{"media_id":"'.$res['media_id'].'"},"msgtype":"mpnews" }'; $res = post_data ( $url, $paramStr ); dump($res); //$neww=$this->get_image_media_id(625); //dump($neww); //$this->display(); } //上传图片到微信 function wximgup($path,$access_token,$u){ $url='https://api.weixin.qq.com/cgi-bin/media/uploadimg'; if(!$u) $url='https://api.weixin.qq.com/cgi-bin/media/upload'; $param ['media'] = '@' . realpath(SITE_PATH . $path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token; $param ['type'] = 'image'; //$param ['media'] = curl_file_create($path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token); $param ['access_token'] = $access_token; return $res = post_data ( $url, $param, true ); } // 新增临时图片素材 function get_image_media_id($cover_id,$access_token) { $cover = get_cover ( $cover_id ); $path = $cover ['path']; /*echo get_access_token ();exit; $key = 'access_token_' . get_token (); echo S ( $key );exit;*/ /*$key = 'access_token_' . get_token (); S ( $key, 0, 7200 );*/ //echo realpath(SITE_PATH . $path);exit; //$access_token=get_access_token (); //$url='https://api.weixin.qq.com/cgi-bin/media/uploadimg'; $url='https://api.weixin.qq.com/cgi-bin/media/upload'; $param ['media'] = '@' . realpath(SITE_PATH . $path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token; $param ['type'] = 'image'; //$param ['media'] = curl_file_create($path);// .'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token); $param ['access_token'] = $access_token; return $res = post_data ( $url, $param, true ); //start $articlesurl='https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token='.$access_token; //$articlesparam ['access_token'] = $access_token; /*$articlesparam ['articles'][0]['thumb_media_id'] = $res['media_id']; $articlesparam ['articles'][0]['author'] = '3432423'; $articlesparam ['articles'][0]['title'] = 'Happy Day'; $articlesparam ['articles'][0]['content_source_url'] = 'www.qq.com'; $articlesparam ['articles'][0]['content'] = 'content'; $articlesparam ['articles'][0]['digest'] = 'digest'; $articlesparam ['articles'][0]['show_cover_pic'] = 1;*/ $jsonArr = array( "articles"=> array( array( // 我就是少了这层array 才会报empty news data 错误 "title"=> 'dingdingdemo', "thumb_media_id"=> $res['media_id'], "author"=> 'martin', "digest"=> 'digest', "show_cover_pic"=> 0, "content"=> $content, "content_source_url"=> 'https://www.baidu.com/', ) ) ); $json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); return post_data ( $articlesurl, $json3, true ); //end return $res['media_id']; echo $path;exit; $driver = C ( 'PICTURE_UPLOAD_DRIVER' ); if ($driver != 'Local' && ! file_exists ( SITE_PATH . $cover ['path'] )) { // 先把图片下载到本地 $pathinfo = pathinfo ( SITE_PATH . $cover ['path'] ); mkdirs ( $pathinfo ['dirname'] ); $content = wp_file_get_contents ( $cover ['url'] ); $res = file_put_contents ( SITE_PATH . $cover ['path'], $content ); if (! $res) { return 0; } } $path = $cover ['path']; if (! $path) { return 0; } $param ['type'] = 'image'; $param ['media'] = '@' . realpath ( SITE_PATH . $path ); $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . get_access_token (); $res = post_data ( $url, $param, true ); if (isset ( $res ['errcode'] ) && $res ['errcode'] != 0) { return $res; } return $res ['media_id']; } function getnewjjfm($src){ //原始图像 $dst = "./a.png"; //实测900*500比例尺寸图片已不会出现裁剪图片边缘的问题,只需要发送多图文消息时注意标题文字是否会挡住图片内容即可。 $minx=900; $miny=500; //得到原始图片信息 $dst_im = imagecreatefrompng($dst); $dst_info = getimagesize($dst); //水印图像 $src = ".".$src; $src_im = imagecreatefromjpeg($src); $src_info = getimagesize($src); $nx=$src_info[0]; $ny=$src_info[1]; if($nx>$minx || $ny>$miny){ //获取大图信息 $maxx=$src_info[0];//宽 $maxy=$src_info[1];//长 $maxt=$src_info[2];//格式 $maxm=$src_info['mime'];//mime类型 //缩放判断 if(($minx/$maxx)>($miny/$maxy)){ $scale=$miny/$maxy; }else{ $scale=$minx/$maxx; } //对所求值进行取整 $minx=floor($maxx*$scale); $miny=floor($maxy*$scale); //添加小图 $minim=imagecreatetruecolor($minx,$miny); //缩放函数 imagecopyresampled($minim,$src_im,0,0,0,0,$minx,$miny,$maxx,$maxy); //imagejpeg($minim); $src_im=$minim; $nx=$minx; $ny=$miny; } //水印透明度 $alpha = 100; $nwx=($dst_info[0]-$nx)/2; $nwy=($dst_info[1]-$ny)/2; //imagealphablending($dst_im , false);//关闭混合模式,以便透明颜色能覆盖原画板 //imagefill($image , 0 , 0 , $bg);//填充 imagesavealpha($dst_im , true);//设置保存PNG时保留透明通道信息 //合并水印图片 imagecopymerge($dst_im,$src_im,$nwx,$nwy,0,0,$nx,$ny,$alpha); //输出合并后水印图片 imagepng($dst_im,'./12345678980.jpg'); imagedestroy($dst_im); imagedestroy($src_im); } }
/Application/Home/View/default/Addons/
lists.html
<extend name="Base/common" /> <block name="body"> <div class="span9 page_message"> <section id="contents"> <include file="Addons/_nav" /> <if condition="$add_button || $del_button || $search_button || !empty($top_more_button)"> <div class="table-bar"> <div class="fl"> <empty name="model.extend"> <div class="tools"> <if condition="$add_button"><php> $add_url || $add_url = U('add?model='.$model['id'], $get_param);</php><a class="btn" href="{$add_url}">新 增</a></if> <if condition="$del_button"><php> $del_url || $del_url = U('del?model='.$model['id'], $get_param);</php><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除</button></if> <php>$url=addons_url ( 'WeiSite://Cms/lists' ); $geturl= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; </php> <if condition="$url eq $geturl"><button class="btn ajax-post confirm create" target-form="ids">生成群发</button> </if> <volist name="top_more_button" id="vo"> <if condition="$vo[is_buttion]"> <button class="btn {$vo.class}" target-form="ids" url="{$vo.url}">{$vo.title}</button> <else /> <a class="btn" href="{$vo.url}">{$vo.title}</a> </if> </volist> </div> </empty> </div> <!-- 高级搜索 --> <if condition="$search_button"> <div class="search-form fr cf"> <div class="sleft"> <php> $get_param[model]=$model['name']; $search_url || $search_url = addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/lists', $get_param);</php> <php>empty($search_key) && $search_key=$model['search_key'];empty($search_key) && $search_key='title';</php> <input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="{$placeholder}"> <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a> </div> </div> </if> </div> </if> <!-- 数据列表 --> <div class="data-table"> <div class="table-striped"> <table cellspacing="1"> <!-- 表头 --> <thead> <tr> <if condition="$check_all"><th class="row-selected row-selected"> <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label></th></if> <volist name="list_grids" id="field"> <th <notempty name="field.width">width="{$field.width}%"</notempty> >{$field.title}</th> </volist> </tr> </thead> <!-- 列表 --> <tbody> <volist name="list_data" id="data"> <tr> <if condition="$check_all"><td><input class="ids regular-checkbox" type="checkbox" value="{$data['id']}" name="ids[]" id="check_{$data['id']}"><label for="check_{$data['id']}"></label></td></if> <volist name="list_grids" id="grid"> <td>{:get_list_field($data,$grid,$model)}</td> </volist> </tr> </volist> </tbody> </table> </div> </div> <div class="page"> {$_page|default=''} </div> </section> </div> </block> <block name="script"> <script type="text/javascript"> $(function(){ //搜索功能 $("#search").click(function(){ var url = $(this).attr('url'); var query = $('.search-form').find('input').serialize(); query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,''); query = query.replace(/^&/g,''); if( url.indexOf('?')>0 ){ url += '&' + query; }else{ url += '?' + query; } window.location.href = url; }); //回车自动提交 $('.search-form').find('input').keyup(function(event){ if(event.keyCode===13){ $("#search").click(); } }); }) </script> <script> $(function(){ $(".create").click(function(){ var checkid = new Array(); $("input[type=checkbox]:checked").each(function(){ // checkid= $(this).val(); if(!(isNaN($(this).val()))) checkid.push($(this).val()); //return checkid; }); //alert(checkid); //var checkid= '1'; $.ajax( { url: '/index.php?s=/addon/Qunsend/Qunsend/allcreate/id/'+checkid+'.html', //这里是静态页的地址 type: "GET", //静态页用get方法,否则服务器会抛出405错误 beforeSend: function(){ }, success: function(data){ return false; alert(data); if(data && data!=0) location.href = '/index.php?s=/addon/Qunsend/Qunsend/lists.html'; else{ alert('生成失败,请重试!'); location.href = '/index.php?s=/addon/WeiSite/Cms/lists.html'; } } }); }); }); </script> </block>
"author"=>$nconfig['bbyueyuesjttsyywxh'],//发布者 "digest"=> $a['intro'],//简介 "show_cover_pic"=> 1,//是否显示封面?
微官网微信订阅号通过点击菜单栏获取openid用户信息
有的认证订阅号有网页授权获取用户基本信息
有的认证订阅号没有网页授权获取用户基本信息
认证服务号是有这个接口权限的,所以用认证服务号开发,不用担心这个接口权限问题
1.用户发消息给你,你收到的xml中有user的openid
2.或者去拉取用户列表
外链图片bug,非src图片img
$content=$s['content']; $content=str_ireplace("data-src=","src=",$content); preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $content, $match);
也是放到网站根目录
show_cover_pic=1
的时候,显示封面是在文章最开头那里显示,一般改0
// 获取当前用户ID define('UID',is_login()); if( !UID ){// 还没登录 跳转到登录页面 $this->redirect('Public/login'); }
$s=M('custom_reply_news')->where('id in ('.$id.')')->order('field(id,'.$id.')')->select(); //按in里面的顺序来排序
非管理员不能查看测试中前端页面,显示正在建设中
class WeiSiteController extends BaseController { var $config; function _initialize() { parent::_initialize(); if(!(is_login())){ $this->display(ONETHINK_ADDON_PATH . 'WeiSite/View/default/TemplateIndex/' . $this->config ['template_index'] . '/cccs.html'); exit; } } function config() {
<!DOCTYPE html> <html> <head> <title>网站正在建设中... </title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="format-detection" content="telephone=no" /> </head> <body> 网站正在建设中... </body> </html>
$Model->field('id,title,content')->select();
class Action{ public function __construct() {
datetimepicker weiphp datetime weiphp日期时间组件 weiphp时间选择
config.php
'bbyueyuesjtfjjs' => array ( 'title' => '放假结束日期时间:', 'type' => 'datetime', 'value' => '', 'tip' => '结束日期要晚于开始日期 到期后自动失效' ),
\Application\Home\View\default\Addons\config.html
<case value="datetime"> <div class="controls"> <input type="datetime" id="{$o_key}" name="config[{$o_key}]" class="text input-large time" value="{$form.value}"> </div> </case> <case value="text"> <div class="controls"> <input type="text" name="config[{$o_key}]" class="text input-large" value="{$form.value}"> </div> </case>
<block name="script"> <link href="__STATIC__/datetimepicker/css/datetimepicker.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css"> <php>if(C('COLOR_STYLE')=='blue_color') echo ' <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css"> ';</php> <link href="__STATIC__/datetimepicker/css/dropdown.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css"> <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.js"></script> <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js?v={:SITE_VERSION}" charset="UTF-8"></script> <script type="text/javascript" charset="utf-8">$(function(){ $('.time').datetimepicker({ format: 'yyyy-mm-dd hh:ii', language:"zh-CN", minView:0, autoclose:true }); $('.date').datetimepicker({ format: 'yyyy-mm-dd', language:"zh-CN", minView:2, autoclose:true }); //showTab(); $('.toggle-data').each(function(){ var data = $(this).attr('toggle-data'); if(data=='') return true; if($(this).is(":selected") || $(this).is(":checked")){ change_event(this) } }); $('.toggle-data').bind("click",function(){ change_event(this) }); }); /*$(function(){ //初始化上传图片插件 initUploadImg(); initUploadFile(); //支持tab showTab(); })*/ </script> </block>
class WeiSiteController extends BaseController { function _initialize() { parent::_initialize (); $bbyueyuesjtfjks=strtotime($this->config ['bbyueyuesjtfjks']); $ntime=time(); $bbyueyuesjtfjjs=strtotime($this->config ['bbyueyuesjtfjjs']); if(!(is_login()) && $ntime>$bbyueyuesjtfjks && $ntime<$bbyueyuesjtfjjs){ $this->ee(); exit; } } function config() {
"content_source_url"=> 'http://bcwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/index.html',//'http://ihosuwx.test2.resonance.net.cn/index.php?s=/addon/WeiSite/WeiSite/lastprice/sp/sp/id/'.$id.'.html',
这里的id应该是数组id
$a['id'] $['s'] //同上标题数组