欧美日韩一区二区视频在线_欧美破处大片在线视频_午夜日韩在线_亚洲高清免费_午夜在线a亚洲v天堂网2018_亚洲午夜久久久久久尤物_国产精品www._久久亚洲一区_亚洲美女色禁图_久久人人精品

快消品貨源批發市場
快消品貨源分銷平臺
 
 
當前位置: 貨源批發網 » 網商學院 » 網店推廣 » 營銷技巧 » 微信營銷 » 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微信接口代碼

分享與收藏:  網商學院搜索  告訴好友  關閉窗口  打印本文 本文關鍵字:
 
更多..資源下載
微信營銷圖文
最先進的病毒式微信營銷模式就是這樣的!!! 想要流量往上漲,微商零售該如何玩?
微信營銷網商學院推薦
微信營銷點擊排行
 
手機版 手機掃描訪問
欧美日韩一区二区视频在线_欧美破处大片在线视频_午夜日韩在线_亚洲高清免费_午夜在线a亚洲v天堂网2018_亚洲午夜久久久久久尤物_国产精品www._久久亚洲一区_亚洲美女色禁图_久久人人精品
亚洲影院久久精品| 91年精品国产| 精品一区二区三区的国产在线播放| 亚洲大尺度视频在线观看| 一区二区三区在线不卡| 日韩精品亚洲专区| 国产精品亚洲人在线观看| 福利视频网站一区二区三区| 色综合视频在线观看| 久久三级视频| 老司机免费视频久久| 精品日韩成人av| 亚洲人成在线观看一区二区| 日本一区中文字幕| 欧美高清不卡| 色狠狠综合天天综合综合| 日韩亚洲电影在线| 亚洲自拍偷拍麻豆| 91原创在线视频| 欧洲色大大久久| √…a在线天堂一区| 国产精品1024久久| 久久成人免费| 国产精品热久久久久夜色精品三区| 日韩专区中文字幕一区二区| 成人av电影观看| 欧美亚洲动漫另类| 一区二区三区国产精华| 女人天堂亚洲aⅴ在线观看| 欧美亚洲综合一区| 亚洲香肠在线观看| 极品裸体白嫩激情啪啪国产精品| 欧美剧情电影在线观看完整版免费励志电影 | 精品国产亚洲一区二区三区在线观看| 成人欧美一区二区三区白人 | 一道本一区二区| 亚洲欧美在线观看| 狠色狠色综合久久| 国产色91在线| 欧美1区2区| 中文字幕高清不卡| 成人高清视频在线观看| 日韩欧美亚洲国产精品字幕久久久 | 一区二区日本视频| 亚洲激情男女视频| 一区二区三区精品国产| 亚洲欧美日韩在线不卡| 极品中文字幕一区| 亚洲国产综合人成综合网站| 一本色道久久综合亚洲精品不 | 蜜桃精品视频在线| 欧美夫妻性生活| 懂色av中文字幕一区二区三区 | 日韩女优av电影在线观看| 成人小视频免费观看| 国产午夜亚洲精品午夜鲁丝片| 欧美高清视频一区| 亚洲一区二区成人在线观看| 色老汉av一区二区三区| 国产精品资源在线| 日韩理论片中文av| 久久久水蜜桃av免费网站| 韩国成人精品a∨在线观看| 日韩视频免费观看高清在线视频| 99久久99久久精品免费看蜜桃| 国产午夜精品在线观看| 性欧美xxxx大乳国产app| 久久国内精品自在自线400部| 欧美一级国产精品| 亚洲三级观看| 国产成人精品网址| 亚洲激情网站免费观看| 欧美欧美欧美欧美首页| 亚洲区一区二区三区| 国产在线精品一区二区不卡了 | 久久亚洲免费视频| 91久久免费观看| 黄色成人精品网站| 国产成人免费视频| 男男gaygay亚洲| 最新成人av在线| 国产午夜精品美女毛片视频| 色婷婷av一区| 国产人成精品一区二区三| eeuss影院一区二区三区| 美女网站视频久久| 亚洲自拍偷拍图区| 中文字幕日韩av资源站| 欧美成人一区二区三区片免费 | 偷偷要91色婷婷| 亚洲欧美日韩国产成人精品影院 | 欧美大片专区| 欧美1区视频| 色综合网站在线| 成人做爰69片免费看网站| 国产美女在线精品| 免费人成黄页网站在线一区二区 | 综合激情网...| 国产精品九色蝌蚪自拍| 中文乱码免费一区二区| 亚洲国产精品成人综合| 国产精品你懂的| 亚洲欧美日韩系列| 亚洲成人动漫在线免费观看| 亚洲伊人色欲综合网| 五月婷婷综合激情| 日日嗨av一区二区三区四区| 久久精品国产在热久久| 久久国产精品99久久人人澡| 国产一区二区91| 99国内精品久久| 99在线|亚洲一区二区| 色婷婷香蕉在线一区二区| 欧美日韩在线三区| 精品国产91久久久久久久妲己| 久久久久国产精品麻豆ai换脸| 国产日韩欧美精品一区| 亚洲一区二区综合| 狠狠狠色丁香婷婷综合久久五月| 狠狠色2019综合网| 国精品一区二区| 久久亚洲色图| 久久久综合视频| 午夜久久久久久| 欧美一区二区三区久久精品茉莉花| 亚洲国产99| 日韩一区二区三区视频在线观看| 欧美国产精品专区| 麻豆国产欧美日韩综合精品二区| 国产成人日日夜夜| 噜噜噜在线观看免费视频日韩| 欧美日韩在线三级| 一区二区三区在线观看欧美| 成人午夜av电影| 色久优优欧美色久优优| 国产精品久久久久久久久图文区 | 国产一区二区三区免费观看| 亚洲午夜激情在线| 久久无码av三级| 国产综合色视频| 色婷婷综合五月| 亚洲激情自拍视频| 国产精品vip| 久久久精品国产免大香伊| 国内外成人在线| 欧美亚男人的天堂| 亚洲国产一区二区a毛片| 亚洲成人在线视频网站| 国产亚洲欧美在线| 99久久er热在这里只有精品15| 欧美片网站yy| 久久精品二区亚洲w码| 一本大道av一区二区在线播放| 亚洲欧美日韩久久| 99在线观看免费视频精品观看| 中文字幕欧美三区| 国内久久精品| 亚洲精品老司机| 久久激情综合| 奇米影视一区二区三区| 欧美在线视频全部完| 日韩av一二三| 欧美一区二区三区公司| 国产a级毛片一区| 久久久久久久久岛国免费| 欧美凹凸一区二区三区视频| 国产精品亲子伦对白| 国产精品免费一区二区三区在线观看 | 99在线精品视频| 亚洲欧美日韩一区| 欧美伊人久久大香线蕉综合69| 蜜桃av噜噜一区二区三区小说| 欧美一区二区三区视频在线| 99视频精品全部免费在线| 国产午夜精品在线观看| 国产女优一区| 激情综合网激情| 国产精品久久一级| 久久综合网络一区二区| 成人午夜电影小说| 亚洲色图另类专区| 日韩欧美一级特黄在线播放| 亚洲三级影院| 北条麻妃一区二区三区| 亚洲国产另类av| 久久综合给合久久狠狠狠97色69| 99在线|亚洲一区二区| 91视频你懂的| 久久99九九99精品| 亚洲久草在线视频| 精品粉嫩超白一线天av| 久久久久久久高潮| 在线午夜精品| 欧美日韩精品综合| 国产不卡一区视频| 精品一区二区三区影院在线午夜| 国产精品初高中害羞小美女文| 51精品视频一区二区三区| 一本一道波多野结衣一区二区| 欧美三级在线|