Joke Collection Website - Public benefit messages - How does php write message push on WeChat public platform?

How does php write message push on WeChat public platform?

Give you a code sample? Can't be copied and used directly.

/**

*? Send template message

*? @param? $tmpId? Template ID

*? @param? $openId? User openID

*? @param? $param? Template parameters

*? @param? $url

*? @ Return? compound

*? @ Author? fjlhuman

*/

Public? Function? sendtpmessage($ tmpId,$openId,$param,$url){

$postUrl? =? "/cgi-bin/message/template/send? Access token = ". $ this-& gt; accessToken

$ arr data[' touser ']= $ openId;

$ arr data[' template _ id ']= $ tmpId; //' 6 ot 8 ddnf-cbiadtsbekskczvhe _ 9 hnhxobt 7 evurnce ';

$ arr data[' URL ']= $ URL;

$ arr data[' data ']= $ param;

$ JSON = JSON _ encode($ arr data);

$ Results? =? Curl::post($postUrl,? $ JSON);

$result=json_decode($result,? True);

$ rData[' isTure ']= false;

$ rData[' msg ']= " ";

if($result['errcode']==0){

$ rData[' isTure ']= true;

$rData['msg']= "Sending succeeded";

} Otherwise {

$ rData[' msg ']= $ result[' errcode '];

}

Return? $ rData

} For details, please refer to? Technical documents of wechat public platform->; Template message interface?