亚洲日本一区二区三区_成人免费网站在线观看_精品久久久网站_精品一区二区三区在线播放视频_日本黄视频网站_九九色在线观看_色综合888

快消品貨源批發市場
快消品貨源分銷平臺
 
 
當前位置: 貨源批發網 » 網商學院 » 網店推廣 » 營銷技巧 » 微信營銷 » destoon微信接口代碼

destoon微信接口代碼

放大字體  縮小字體 發布日期:2025-10-28 06:42:09  來源:電商聯盟  作者:樂發網  瀏覽次數:284

<?php

class Wechat
{
const MSGTYPE_TEXT = 'text';
const MSGTYPE_IMAGE = 'image';
const MSGTYPE_LOCATION = 'location';
const MSGTYPE_link = 'link';
const MSGTYPE_EVENT = 'event';
const MSGTYPE_MUSIC = 'music';
const MSGTYPE_NEWS = 'news';
const MSGTYPE_VOICE = 'voice';
const MSGTYPE_VIDEO = 'video';
const API_URL_PREFIX = 'https://api.weixin.qq.com/cgi-bin';
const AUTH_URL = '/token?grant_type=client_credential&';
const MENU_CREATE_URL = '/menu/create?';
const MENU_GET_URL = '/menu/get?';
const MENU_DELETE_URL = '/menu/delete?';
const MEDIA_GET_URL = '/media/get?';

private $token;
private $appid;
private $appsecret;
private $access_token;
private $_msg;
private $_funcflag = false;
private $_receive;
public $debug = false;
public $errCode = 40001;
public $errMsg = "no access";
private $_logcallback;

public function __construct($options)
{
$this->token = isset($options['token'])?$options['token']:'';
$this->appid = isset($options['appid'])?$options['appid']:'';
$this->appsecret = isset($options['appsecret'])?$options['appsecret']:'';
$this->debug = isset($options['debug'])?$options['debug']:false;
$this->_logcallback = isset($options['logcallback'])?$options['logcallback']:false;
}


private function checkSignature()
{
$signature = isset($_GET["signature"])?$_GET["signature"]:'';
$timestamp = isset($_GET["timestamp"])?$_GET["timestamp"]:'';
$nonce = isset($_GET["nonce"])?$_GET["nonce"]:'';

$token = $this->token;
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );

if( $tmpStr == $signature ){
return true;
}else{
return false;
}
}


public function valid($return=false)
{
$echoStr = isset($_GET["echostr"]) ? $_GET["echostr"]: '';
if ($return) {
if ($echoStr) {
if ($this->checkSignature())
return $echoStr;
else
return false;
} else
return $this->checkSignature();
} else {
if ($echoStr) {
if ($this->checkSignature())
die($echoStr);
else
die('no access');
} else {
if ($this->checkSignature())
return true;
else
die('no access');
}
}
return false;
}


public function Message($msg = '',$append = false){
if (is_null($msg)) {
$this->_msg =array();
}elseif (is_array($msg)) {
if ($append)
$this->_msg = array_merge($this->_msg,$msg);
else
$this->_msg = $msg;
return $this->_msg;
} else {
return $this->_msg;
}
}

public function setFuncFlag($flag) {
$this->_funcflag = $flag;
return $this;
}

private function log($log){
if ($this->debug && function_exists($this->_logcallback)) {
if (is_array($log)) $log = print_r($log,true);
return call_user_func($this->_logcallback,$log);
}
}


public function getRev()
{
$postStr = file_get_contents("php://input");
$this->log($postStr);
if (!empty($postStr)) {
$this->_receive = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
}
return $this;
}


public function getRevData()
{
return $this->_receive;
}


public function getRevFrom() {
if ($this->_receive)
return $this->_receive['FromUserName'];
else
return false;
}


public function getRevTo() {
if ($this->_receive)
return $this->_receive['ToUserName'];
else
return false;
}


public function getRevType() {
if (isset($this->_receive['MsgType']))
return $this->_receive['MsgType'];
else
return false;
}


public function getRevID() {
if (isset($this->_receive['MsgId']))
return $this->_receive['MsgId'];
else
return false;
}


public function getRevCtime() {
if (isset($this->_receive['CreateTime']))
return $this->_receive['CreateTime'];
else
return false;
}


public function getRevContent(){
if (isset($this->_receive['Content']))
return $this->_receive['Content'];
else if (isset($this->_receive['Recognition'])) //獲取語音識別文字內容,需申請開通
return $this->_receive['Recognition'];
else
return false;
}


public function getRevPic(){
if (isset($this->_receive['PicUrl']))
return $this->_receive['PicUrl'];
else
return false;
}


public function getRevlink(){
if (isset($this->_receive['Url'])){
return array(
'url'=>$this->_receive['Url'],
'title'=>$this->_receive['Title'],
'description'=>$this->_receive['Description']
);
} else
return false;
}


public function getRevGeo(){
if (isset($this->_receive['Location_X'])){
return array(
'x'=>$this->_receive['Location_X'],
'y'=>$this->_receive['Location_Y'],
'scale'=>$this->_receive['Scale'],
'label'=>$this->_receive['Label']
);
} else
return false;
}


public function getRevEvent(){
if (isset($this->_receive['Event'])){
return array(
'event'=>$this->_receive['Event'],
'key'=>$this->_receive['EventKey'],
);
} else
return false;
}


public function getRevVoice(){
if (isset($this->_receive['MediaId'])){
return array(
'mediaid'=>$this->_receive['MediaId'],
'format'=>$this->_receive['Format'],
);
} else
return false;
}


public function getRevVideo(){
if (isset($this->_receive['MediaId'])){
return array(
'mediaid'=>$this->_receive['MediaId'],
'thumbmediaid'=>$this->_receive['ThumbMediaId']
);
} else
return false;
}

public static function xmlSafeStr($str)
{
return '<![CDATA['.preg_replac("/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/",'',$str).']]>';
}


public static function data_to_xml($data) {
$xml = '';
foreach ($data as $key => $val) {
is_numeric($key) && $key = "item id=\"$key\"";
$xml .= "<$key>";
$xml .= ( is_array($val) || is_object($val)) ? self::data_to_xml($val) : self::xmlSafeStr($val);
list($key, ) = explode(' ', $key);
$xml .= "</$key>";
}
return $xml;
}


public function xml_encode($data, $root='xml', $item='item', $attr='', $id='id', $encoding='utf-8') {
if(is_array($attr)){
$_attr = array();
foreach ($attr as $key => $value) {
$_attr[] = "{$key}=\"{$value}\"";
}
$attr = implode(' ', $_attr);
}
$attr = trim($attr);
$attr = empty($attr) ? '' : " {$attr}";
$xml = "<{$root}{$attr}>";
$xml .= self::data_to_xml($data, $item, $id);
$xml .= "</{$root}>";
return $xml;
}


public function text($text='')
{
$FuncFlag = $this->_funcflag ? 1 : 0;
$msg = array(
'ToUserName' => $this->getRevFrom(),
'FromUserName'=>$this->getRevTo(),
'MsgType'=>self::MSGTYPE_TEXT,
'Content'=>$text,
'CreateTime'=>time(),
'FuncFlag'=>$FuncFlag
);
$this->Message($msg);
return $this;
}


public function music($title,$desc,$musicurl,$hgmusicurl='') {
$FuncFlag = $this->_funcflag ? 1 : 0;
$msg = array(
'ToUserName' => $this->getRevFrom(),
'FromUserName'=>$this->getRevTo(),
'CreateTime'=>time(),
'MsgType'=>self::MSGTYPE_MUSIC,
'Music'=>array(
'Title'=>$title,
'Description'=>$desc,
'MusicUrl'=>$musicurl,
'HQMusicUrl'=>$hgmusicurl
),
'FuncFlag'=>$FuncFlag
);
$this->Message($msg);
return $this;
}

public function news($newsData=array())
{
$FuncFlag = $this->_funcflag ? 1 : 0;
$count = count($newsData);

$msg = array(
'ToUserName' => $this->getRevFrom(),
'FromUserName'=>$this->getRevTo(),
'MsgType'=>self::MSGTYPE_NEWS,
'CreateTime'=>time(),
'ArticleCount'=>$count,
'Articles'=>$newsData,
'FuncFlag'=>$FuncFlag
);
$this->Message($msg);
return $this;
}


public function reply($msg=array(),$return = false)
{
if (empty($msg))
$msg = $this->_msg;
$xmldata= $this->xml_encode($msg);
$this->log($xmldata);
if ($return)
return $xmldata;
else
echo $xmldata;
}



private function http_get($url){
$oCurl = curl_init();
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}


private function http_post($url,$param){
$oCurl = curl_init();
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
}
if (is_string($param)) {
$strPOST = $param;
} else {
$aPOST = array();
foreach($param as $key=>$val){
$aPOST[] = $key."=".urlencode($val);
}
$strPOST = join("&", $aPOST);
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($oCurl, CURLOPT_POST,true);
curl_setopt($oCurl, CURLOPT_POSTFIELDS,$strPOST);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}


public function checkAuth($appid='',$appsecret=''){
if (!$appid || !$appsecret) {
$appid = $this->appid;
$appsecret = $this->appsecret;
}
//TODO: get the cache access_token
$result = $this->http_get(self::API_URL_PREFIX.self::AUTH_URL.'appid='.$appid.'&secret='.$appsecret);
if ($result)
{
$json = json_decode($result,true);
if (!$json || isset($json['errcode'])) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return false;
}
$this->access_token = $json['access_token'];
$expire = $json['expires_in'] ? intval($json['expires_in'])-100 : 3600;
//TODO: cache access_token
return $this->access_token;
}
return false;
}


public function resetAuth($appid=''){
$this->access_token = '';
//TODO: remove cache
return true;
}


static function json_encode($arr) {
$parts = array ();
$is_list = false;
//Find out if the given array is a numerical array
$keys = array_keys ( $arr );
$max_length = count ( $arr ) - 1;
if (($keys [0] === 0) && ($keys [$max_length] === $max_length )) { //See if the first key is 0 and last key is length - 1
$is_list = true;
for($i = 0; $i < count ( $keys ); $i ++) { //See if each key correspondes to its position
if ($i != $keys [$i]) { //A key fails at position check.
$is_list = false; //It is an associative array.
break;
}
}
}
foreach ( $arr as $key => $value ) {
if (is_array ( $value )) { //Custom handling for arrays
if ($is_list)
$parts [] = self::json_encode ( $value );
else
$parts [] = '"' . $key . '":' . self::json_encode ( $value );
} else {
$str = '';
if (! $is_list)
$str = '"' . $key . '":';
//Custom handling for multiple data types
if (is_numeric ( $value ) && $value<2000000000)
$str .= $value; //Numbers
elseif ($value === false)
$str .= 'false'; //The booleans
elseif ($value === true)
$str .= 'true';
else
$str .= '"' . addslashes ( $value ) . '"'; //All other things
// :TODO: Is there any more datatype we should be in the lookout for? (Object?)
$parts [] = $str;
}
}
$json = implode ( ',', $parts );
if ($is_list)
return '[' . $json . ']'; //Return numerical JSON
return '{' . $json . '}'; //Return associative JSON
}


public function createMenu($data){
if (!$this->access_token && !$this->checkAuth()) return false;
$result = $this->http_post(self::API_URL_PREFIX.self::MENU_CREATE_URL.'access_token='.$this->access_token,self::json_encode($data));
if ($result)
{
$json = json_decode($result,true);
if (!$json || $json['errcode']>0) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return false;
}
return true;
}
return false;
}


public function getMenu(){
if (!$this->access_token && !$this->checkAuth()) return false;
$result = $this->http_get(self::API_URL_PREFIX.self::MENU_GET_URL.'access_token='.$this->access_token);
if ($result)
{
$json = json_decode($result,true);
if (!$json || isset($json['errcode'])) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return false;
}
return $json;
}
return false;
}


public function deleteMenu(){
if (!$this->access_token && !$this->checkAuth()) return false;
$result = $this->http_get(self::API_URL_PREFIX.self::MENU_DELETE_URL.'access_token='.$this->access_token);
if ($result)
{
$json = json_decode($result,true);
if (!$json || $json['errcode']>0) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return false;
}
return true;
}
return false;
}


public function getMedia($media_id){
if (!$this->access_token && !$this->checkAuth()) return false;
$result = $this->http_get(self::API_URL_PREFIX.self::MEDIA_GET_URL.'access_token='.$this->access_token).'&media_id='.$media_id;
if ($result)
{
$json = json_decode($result,true);
if (isset($json['errcode'])) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return false;
}
return $result;
}
return false;
}
}

快消品貨源網提供超市貨源信息,超市采購進貨渠道。超市進貨網提供成都食品批發,日用百貨批發信息、微信淘寶網店超市采購信息和超市加盟信息.打造國內超市采購商與批發市場供應廠商搭建網上批發市場平臺,是全國批發市場行業中電子商務權威性網站。

本文內容整合網站:百度百科知乎淘寶平臺規則

本文來源: destoon微信接口代碼

分享與收藏:  網商學院搜索  告訴好友  關閉窗口  打印本文 本文關鍵字:
 
更多..資源下載
微信營銷圖文
最先進的病毒式微信營銷模式就是這樣的!!! 想要流量往上漲,微商零售該如何玩?
微信營銷網商學院推薦
微信營銷點擊排行
 
手機版 手機掃描訪問
亚洲日本一区二区三区_成人免费网站在线观看_精品久久久网站_精品一区二区三区在线播放视频_日本黄视频网站_九九色在线观看_色综合888
成人免费毛片嘿嘿连载视频| 亚洲国产精品av| 亚洲一区在线观看网站| 91精品国产日韩91久久久久久| 国产成人精品一区二区三区网站观看| 亚洲一区在线电影| 中文字幕在线一区| 精品裸体舞一区二区三区| 在线视频国内一区二区| 成人免费看的视频| 加勒比av一区二区| 日本亚洲视频在线| 亚洲大片一区二区三区| 最新成人av在线| 国产精品毛片久久久久久久| xnxx国产精品| 久久综合色天天久久综合图片| 欧美久久一二三四区| 色播五月激情综合网| 成人激情文学综合网| 国产精品亚洲人在线观看| 奇米一区二区三区av| 午夜成人免费视频| 五月天国产精品| 日韩精品一级二级 | 91精品国产欧美一区二区18| 欧美性一二三区| 欧美日韩一级二级三级| 欧美日韩免费在线视频| 欧美美女直播网站| 欧美日韩国产美女| 欧美精品九九99久久| 欧美一区午夜视频在线观看 | 国产乱码精品一区二区三区五月婷| 日产精品久久久久久久性色| 日韩av一区二区三区| 久久电影网站中文字幕| 国产乱子伦一区二区三区国色天香| 美女www一区二区| 国产美女娇喘av呻吟久久| 国产成人免费在线| 99视频精品在线| 在线观看日韩电影| 日韩欧美中文字幕精品| 久久综合色播五月| 亚洲天堂精品在线观看| 亚洲午夜激情网页| 久久精品999| 91网上在线视频| 欧美日韩高清影院| 久久综合色天天久久综合图片| 国产精品久久久久久久久久久免费看 | 欧美色区777第一页| 欧美日韩国产另类一区| 久久夜色精品国产欧美乱极品| 国产免费观看久久| 亚洲国产欧美在线| 国产乱一区二区| 色94色欧美sute亚洲线路一ni| 欧美老肥妇做.爰bbww| 久久久久久久综合日本| 亚洲欧美日韩国产中文在线| 亚洲va国产va欧美va观看| 国产一区二区网址| 欧美日韩一区二区三区四区五区| 久久久久久亚洲综合影院红桃| 一区二区三区在线播| 激情欧美一区二区| 91精品福利视频| 国产调教视频一区| 麻豆久久久久久久| 色欲综合视频天天天| 精品久久一区二区| 亚洲成人午夜电影| eeuss鲁片一区二区三区| 欧美一区二区精品| 亚洲一区二区精品视频| 成人精品小蝌蚪| 精品日韩欧美一区二区| 一区二区三区四区蜜桃| 国产乱码一区二区三区| 欧美一区二区三区免费视频| 樱花草国产18久久久久| 高潮精品一区videoshd| 日韩欧美资源站| 亚洲va韩国va欧美va精品| www.亚洲人| 国产欧美日韩精品一区| 九一九一国产精品| 欧美一区二区三区免费观看视频| 亚洲在线视频网站| 99久久精品免费看| 一区在线观看视频| 国产麻豆成人传媒免费观看| 在线综合视频播放| 日韩精品一二三| 欧美日韩国产不卡| 有码一区二区三区| 一本久道久久综合中文字幕| 国产人成亚洲第一网站在线播放| 久久精品国产99国产| 88在线观看91蜜桃国自产| 亚洲成人av在线电影| 精品视频999| 欧美一区日韩一区| 亚洲午夜免费视频| 在线观看国产一区二区| 亚洲一区二区影院| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 精品日韩在线观看| 久久99久久99| 日韩你懂的在线播放| 在线看国产一区二区| 亚洲图片激情小说| 在线免费观看一区| 视频在线观看一区| 日韩欧美一区电影| 久久99精品久久久久久久久久久久| 精品蜜桃在线看| 福利电影一区二区| 中文字幕在线视频一区| 91福利视频网站| 日韩高清欧美激情| ww亚洲ww在线观看国产| 国产精品亚洲а∨天堂免在线| 国产日本欧美一区二区| 99re热视频这里只精品| 亚洲国产精品久久久男人的天堂| 666欧美在线视频| 国产精品综合视频| 亚洲精品日日夜夜| 91精品国产综合久久精品app | 色综合久久久久网| 爽好多水快深点欧美视频| 精品国产露脸精彩对白| 成人网男人的天堂| 亚洲福利一区二区| 久久婷婷成人综合色| 色天使久久综合网天天| 日本亚洲欧美天堂免费| 国产精品少妇自拍| 欧美偷拍一区二区| 国产一区二区按摩在线观看| 国产精品理伦片| 67194成人在线观看| 99re这里只有精品首页| 麻豆免费看一区二区三区| 国产精品电影院| 日韩欧美一二三四区| 成人国产免费视频| 蜜臀av国产精品久久久久 | 欧美老肥妇做.爰bbww| 高清成人免费视频| 青青草视频一区| 亚洲男人的天堂av| 久久久久久久综合日本| 欧美日本高清视频在线观看| 国产99久久久精品| 日韩中文字幕麻豆| 亚洲欧美在线视频| 久久精品视频一区| 91精品国产一区二区人妖| 色悠悠亚洲一区二区| 国产一区二区91| 久久精品国产亚洲一区二区三区| 一区二区三区产品免费精品久久75 | 精品国产一区二区三区忘忧草 | 成人性生交大片免费看在线播放| 午夜日韩在线观看| 亚洲免费视频成人| 国产精品久久久久久一区二区三区| 精品日韩成人av| 日韩精品中文字幕一区二区三区| 欧美在线视频日韩| 欧美亚洲一区二区在线| 91亚洲午夜精品久久久久久| 丁香婷婷综合色啪| 国产**成人网毛片九色| 国产ts人妖一区二区| 久久99精品久久久久| 免费成人在线视频观看| 日韩高清中文字幕一区| 日韩电影在线观看网站| 香蕉成人伊视频在线观看| 亚洲一区在线视频| 亚洲mv在线观看| 午夜精品福利在线| 无码av中文一区二区三区桃花岛| 亚洲午夜影视影院在线观看| 夜夜揉揉日日人人青青一国产精品| 亚洲中国最大av网站| 午夜精品在线视频一区| 青青国产91久久久久久| 理论电影国产精品| 国产一区二区成人久久免费影院| 国产丶欧美丶日本不卡视频| 成人高清视频免费观看| av资源网一区| 色屁屁一区二区| 欧美精品少妇一区二区三区|