微信模版訊息推送

2021-08-14 23:52:06 字數 2182 閱讀 4964

class

weixinpush

}/**

* 傳送post請求

* @param string $url

* @param string $param

* @return bool|mixed

*/function

request_post

($url = '', $param = '')

$posturl = $url;

$curlpost = $param;

$ch = curl_init(); //初始化curl

curl_setopt($ch, curlopt_url, $posturl); //抓取指定網頁

curl_setopt($ch, curlopt_header, 0); //設定header

curl_setopt($ch, curlopt_returntransfer, 1); //要求結果為字串且輸出到螢幕上

curl_setopt($ch, curlopt_post, 1); //post提交方式

curl_setopt($ch, curlopt_postfields, $curlpost);

$data = curl_exec($ch); //執行curl

curl_close($ch);

return $data;

}/**

* 傳送get請求

* @param string $url

* @return bool|mixed

*/function

request_get

($url = '')

$ch = curl_init();

curl_setopt($ch, curlopt_url, $url);

curl_setopt($ch, curlopt_returntransfer, 1);

$data = curl_exec($ch);

curl_close($ch);

return $data;

}/**

* 獲取token

* @return mixed

*/protected

function

gettoken

/*** 傳送自定義的模板訊息

* @param $touser

* @param $template_id

* @param $url

* @param $data

* @param string $topcolor

* @return bool

*/public

function

dosend

($touser, $template_id, $url, $type, $topcolor = '#7b68ee')

else

}}$data = array(

'first'=>array('value'=>urlencode("您的訂單已提交成功"),'color'=>"#743a3a"),

'orderid'=>array('value'=>urlencode("123456789"),'color'=>"#743a3a"),

'ordermoneysum'=>array('value'=>urlencode("30.0"),'color'=>'#0000ff'),

'backupfieldname'=>array('value'=>urlencode("商品資訊"),'color'=>'#0000ff'),

'backupfielddata'=>array('value'=>urlencode("商品名稱"),'color'=>'#0000ff'),

$touser就是接受你訊息那個人的openid

企業微信訊息推送

獲取token admin admin adminservice.getcurrent crop co cropservice.findbyadmin admin.getid stringbuffer str newstringbuffer co.setsecret co.getsecret str...

微信模板訊息推送

2 傳送模板訊息 使用者openid 車牌號 司機姓名 發生區域 違章日期 違章內容 備註 private string sendmessage string open id,string car no,string name,string address,string date,string co...

python使用微信推送訊息

from wxpy import import requests from datetime import datetime import time import schedule from apscheduler.schedulers.blocking import blockingschedul...