SEARCH
新闻资讯

网站知识库

企业怎么建立本身的微官网,其实很简单

2020/4/19 12:04:25

其实我们认为如今的人把微站神话了,在我们的概念里,其实他就和百度,网址一样只是一个入口而已,没有什么难处,只不过有些是必须要,单独的手机网站,来做为微网站的落地页的。
1:首先,必须要在微信公众平台上注册一个本身的服务号或者订阅号,这一步其实很简单的。

企业怎么建立本身的微官网,其实很简单


2:申请公众账号成功后,其实就等于你已经有了本身的为网站了,便可以使用其基本功能了,当然,要想做成本身的微信官网,则必须要进入开发模式,接入第三方接口。或者利用手机网站做,手机网站模板参考http://www.ccxcn.com/mobile

企业怎么建立本身的微官网,其实很简单

企业怎么建立本身的微官网,其实很简单


3:注册成功并登陆第三方接口,将注册好的微信公众号添加到第三方接口上,所需信息在微信公众号设置下的账号信息里。

企业怎么建立本身的微官网,其实很简单


4:添加公众账号后,连接公众平台与第三方接口,如图:登录微信公众平台,点击最左侧最下方的【开发者中间】,点击开发模式。

企业怎么建立本身的微官网,其实很简单


第五步:最后,设计本身的微信官网。并且可在线预览。

企业怎么建立本身的微官网,其实很简单


完成以上步骤后,并且认证订阅号或服务号后就可以做微信的二次开发了,比如我要制作一个群发功能的接口,必须要使用一下微信接口:
1、获取access token
2、新增一时素材接口
3、上传图文新闻素材接口
4、调用群发接口
接口代码示例:WeixinApi.class.php
<?php
class WeixinApi{
private $appid,$appsecret,$media_id;
public function __construct($appid="",$appsecret=""){
$this->appid=$appid;
$this->appsecret=$appsecret;
}
//获取token
public function getToken(){
if($_COOKIE["exptime"]=="" || time()-$_COOKIE["create_time"]>=$_COOKIE["exptime"]){
$token=@file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appid}&secret={$this->appsecret}");
$tokenarr=json_decode($token,true);
setcookie("exptime",$tokenarr["expires_in"],0,'/');
setcookie("access_token",$tokenarr["access_token"],0,'/');
setcookie("create_time",time(),0,'/');
}else{
$tokenarr=array(
"access_token"=>$_COOKIE["access_token"],
"expires_in"=>$_COOKIE["exptime"],
"create_time"=>$_COOKIE["create_time"]
);
}
return $tokenarr;
}
private function sockupload($phost,$pport,$purl,$filename,$file_data=array()){
$host = $phost;
$port = $pport;
$errno = '';
$errstr = '';
$timeout = 30;
$url = $purl;
/*$form_data = array(
'name' => 'lijie',
'gender' => 'man',
);*/
$file_data = array(
array(
'name' => 'media',
'filename' => $filename,
//'path' =>'1.jpg'
)
);
// create connect
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
if(!$fp){
return false;
}
// send request
srand((double)microtime()*1000000);
$boundary = "---------------------------".substr(md5(rand(0,32000)),0,10);
$data = "--$boundaryrn";
// form data
if(count($form_data)>0){
foreach($form_data as $key=>$val){
$data .= "Content-Disposition: form-data; name="".$key.""rn";
$data .= "Content-type:text/plainrnrn";
$data .= rawurlencode($val)."rn";
$data .= "--$boundaryrn";
}
}
// file data
if($filename!=""){
foreach($file_data as $file){
$data .= "Content-Disposition: form-data; name="".$file['name'].""; filename="".$file['filename'].""rn";
$pinfo=pathinfo($file['filename']);
$data .= "Content-Type: ".$pinfo["extension"]."rnrn";
$data .= implode("",file($file['filename']))."rn";
$data .= "--$boundaryrn";
}
}
$data .="--rnrn";
$out = "POST ${url} HTTP/1.1rn";
$out .= "Host:${host}rn";
$out .= "Content-type:multipart/form-data; boundary=$boundaryrn"; // multipart/form-data
$out .= "Content-length:".strlen($data)."rn";
$out .= "Connection:closernrn";
$out .= "${data}";
fputs($fp, $out);
// get response
$response = '';
while($row=fread($fp, 4096)){
$response .= $row;
}
$pos = strpos($response, "rnrn");
$response = substr($response, $pos+4);
return $response;
}
//json数据提交
private function jsonUpload($url,$jsdata){
$data_string = $jsdata;
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json;charset=utf-8',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
curl_close ( $ch );
return $result;
}
//上传媒体接口
public function upload($type,$filename){
$tokens=$this->getToken();
$result=$this->sockupload("api.weixin.qq.com",80,"/cgi-bin/media/upload?access_token=".$tokens["access_token"]."&type={$type}",$filename);
$media=json_decode($result,true);
$this->media_id=$media['media_id'];
return $this;
}
//上传素材
public function uploadnews($title,$content,$author="",$url="",$digest="",$show_cover_pic="1"){
$articles=array(
"articles"=>array(
array(
"thumb_media_id"=>$this->media_id,
"author"=>$author,
"title"=>urlencode($title),
"content_source_url"=>$url,
"content"=>urlencode($content),
"digest"=>$digest,
"show_cover_pic"=>"1"
)
)
);
$tokens=$this->getToken();
$news=urldecode(json_encode($articles));
$result=$this->jsonUpload("api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=".$tokens["access_token"]."",$news);
$newsdata=json_decode($result,true);
$this->media_id=$newsdata["media_id"];
return $this;
}
//群发接口
public function sendall(){
$arr=array(
"filter"=>array("is_to_all"=>true,"group_id"=>""),
"mpnews"=>array("media_id"=>$this->media_id),
"msgtype"=>"mpnews"
);
$json=json_encode($arr);
$tokens=$this->getToken();
$result=$this->jsonUpload("api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=".$tokens["access_token"]."",$json);
return $result;
}
}
使用:
$weixin=new WeixinApi($appid,$appsecret);
$result=$weixin->upload("image","图片路径")->uploadnews("文章题目","文章内容")->sendall();

微官网是为适应高速发展的移动互联网市场环境而诞生的一种基于WebApp和传统PC版网站相融合的新型网站。微官网可兼容iOS、android、WP等多种智能手机操作体系,可便捷的与微信、微博等网络互动咨询平台链接,简言之,微官网就是适应移动客户端欣赏体验与交互性能要求的新一代网站。
好处

1、不用注册域名更方便
         2、不用购买空间更节约
         3、不用进行网站备案更省时

 

4、多款行业模版随意选择,多种内页列表显现方法,布局采用DIV+CSS技术,简洁大方,拓展性强,无穷制页面数量与容量,页面图片任意编辑,主动适应屏幕比例,移动客户端界面视觉结果强,版面雄厚,布局天真,扩展性强

5、应用HTML5技术提高欣赏体验与交互性能,访问速度更快,更安全,用户体验更佳
6、内置一键导航功能,可个性化定制功能模块,自定义微网站导航
7、提供在线付出,购物,等多种电商移动互联网开发


如没特殊注明,文章均为成都网站建设公司唯赛网络原创,转载请注明来自http://www.weseo.cn/News/knowledge_675_12013.html

Contact

ADD:成都市青羊区光华东三路西环广场6楼

TEL:028-64232097

Wechat

微信二维码