MENU 服務(wù) 案例
網(wǎng)站建設(shè)-網(wǎng)站設(shè)計(jì)-北京網(wǎng)站建設(shè)-高端網(wǎng)站制作公司-尚品中國(guó)
我們通過(guò)擁抱變化創(chuàng)造
360°的品牌價(jià)值__
簡(jiǎn)體
簡(jiǎn)體中文 English

尚品簽約辰欣藥業(yè)股份有限公司官網(wǎng)建設(shè)

類(lèi)型:尚品動(dòng)態(tài) 了解更多

微網(wǎng)站制作教程圖解

來(lái)源:尚品中國(guó)| 類(lèi)型:網(wǎng)站百科| 時(shí)間:2017-07-19
尚品中國(guó)網(wǎng)站制作公司最近發(fā)現(xiàn)特別多的人在問(wèn)微網(wǎng)站是什么,微網(wǎng)站有什么用,微網(wǎng)站怎么做,微網(wǎng)站建設(shè)流程等問(wèn)題,今天,在這里為大家統(tǒng)一解答,希望能對(duì)各位愛(ài)學(xué)習(xí)人士有所幫助。

第一步:首先,需要在微信公眾平臺(tái)上注冊(cè)一個(gè)自己的服務(wù)號(hào)或者訂閱號(hào)。

微網(wǎng)站制作教程圖解1:注冊(cè)自己的服務(wù)號(hào)或者訂閱號(hào)

第二步:申請(qǐng)公眾賬號(hào)成功后,便可以使用其基本功能了,當(dāng)然,要想做成自己的微信官網(wǎng),則需要進(jìn)入開(kāi)發(fā)模式,接入第三方接口。

微網(wǎng)站制作教程圖解2微網(wǎng)站制作圖解3微官網(wǎng)

第三步:注冊(cè)成功并登陸第三方接口,將注冊(cè)好的微信公眾號(hào)添加到第三方接口上,所需信息在微信公眾號(hào)設(shè)置下的賬號(hào)信息里。

注冊(cè)成功并登陸第三方接口

第四步:添加公眾賬號(hào)后,連接公眾平臺(tái)與第三方接口,如圖:登錄微信公眾平臺(tái),點(diǎn)擊最左側(cè)最下方的【開(kāi)發(fā)者中心】,點(diǎn)擊開(kāi)發(fā)模式。

登錄微信公眾平臺(tái)

第五步:最后,設(shè)計(jì)自己的微信官網(wǎng)。并且可在線(xiàn)預(yù)覽。

設(shè)計(jì)自己的微信官網(wǎng),并且可在線(xiàn)預(yù)覽


完成以上步驟后,并且認(rèn)證訂閱號(hào)或服務(wù)號(hào)后就可以做微信的二次開(kāi)發(fā)了,比如我要制作一個(gè)群發(fā)功能的接口,需要使用一下微信接口:

1、獲取access token

2、新增臨時(shí)素材接口

3、上傳圖文消息素材接口

4、調(diào)用群發(fā)接口

接口代碼示例: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數(shù)據(jù)提交
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;
}

//群發(fā)接口
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("文章標(biāo)題","文章內(nèi)容")->sendall();
來(lái)源聲明:本文章系尚品中國(guó)編輯原創(chuàng)或采編整理,如需轉(zhuǎn)載請(qǐng)注明來(lái)自尚品中國(guó)。以上內(nèi)容部分(包含圖片、文字)來(lái)源于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)及時(shí)與本站聯(lián)系(010-60259772)。
TAG標(biāo)簽:

如果您的網(wǎng)站可以增加轉(zhuǎn)化次數(shù)并提高客戶(hù)滿(mǎn)意度,該怎么辦?

預(yù)約專(zhuān)業(yè)咨詢(xún)顧問(wèn)溝通!

*尚品專(zhuān)業(yè)顧問(wèn)將盡快與您聯(lián)系

免責(zé)聲明

非常感謝您訪(fǎng)問(wèn)我們的網(wǎng)站。在您使用本網(wǎng)站之前,請(qǐng)您仔細(xì)閱讀本聲明的所有條款。

1、本站部分內(nèi)容來(lái)源自網(wǎng)絡(luò),涉及到的部分文章和圖片版權(quán)屬于原作者,本站轉(zhuǎn)載僅供大家學(xué)習(xí)和交流,切勿用于任何商業(yè)活動(dòng)。

2、本站不承擔(dān)用戶(hù)因使用這些資源對(duì)自己和他人造成任何形式的損失或傷害。

3、本聲明未涉及的問(wèn)題參見(jiàn)國(guó)家有關(guān)法律法規(guī),當(dāng)本聲明與國(guó)家法律法規(guī)沖突時(shí),以國(guó)家法律法規(guī)為準(zhǔn)。

4、如果侵害了您的合法權(quán)益,請(qǐng)您及時(shí)與我們,我們會(huì)在第一時(shí)間刪除相關(guān)內(nèi)容!

聯(lián)系方式:010-60259772
電子郵件:394588593@qq.com

現(xiàn)在就與專(zhuān)業(yè)咨詢(xún)顧問(wèn)溝通!

  • 全國(guó)服務(wù)熱線(xiàn)

    400-700-4979

  • 北京服務(wù)熱線(xiàn)

    010-60259772

信息保護(hù)中請(qǐng)放心填寫(xiě)
在線(xiàn)咨詢(xún)

免責(zé)聲明

非常感謝您訪(fǎng)問(wèn)我們的網(wǎng)站。在您使用本網(wǎng)站之前,請(qǐng)您仔細(xì)閱讀本聲明的所有條款。

1、本站部分內(nèi)容來(lái)源自網(wǎng)絡(luò),涉及到的部分文章和圖片版權(quán)屬于原作者,本站轉(zhuǎn)載僅供大家學(xué)習(xí)和交流,切勿用于任何商業(yè)活動(dòng)。

2、本站不承擔(dān)用戶(hù)因使用這些資源對(duì)自己和他人造成任何形式的損失或傷害。

3、本聲明未涉及的問(wèn)題參見(jiàn)國(guó)家有關(guān)法律法規(guī),當(dāng)本聲明與國(guó)家法律法規(guī)沖突時(shí),以國(guó)家法律法規(guī)為準(zhǔn)。

4、如果侵害了您的合法權(quán)益,請(qǐng)您及時(shí)與我們,我們會(huì)在第一時(shí)間刪除相關(guān)內(nèi)容!

聯(lián)系方式:010-60259772
電子郵件:394588593@qq.com