<?php
#global $wpdb, $ft_tables;
#$token = '123';//微信-客服消息TOKEN(令牌)
#
#$signature = $_GET["signature"];
#$timestamp = $_GET["timestamp"];
#$nonce = $_GET["nonce"];
#
#$tmpArr = array($token, $timestamp, $nonce);
#sort($tmpArr, SORT_STRING);
#$tmpStr = implode($tmpArr);
#$tmpStr = sha1($tmpStr);
#
#if ($tmpStr == $signature) {
# echo $_GET['echostr'];
#} else {
# echo 'xx';
#}
//获取token
include_once "./token.php";
//接收用户消息
$jsonString = file_get_contents("php://input");
// file_put_contents(__DIR__.'/wechat.log',print_r($jsonString,true),8);
if (!empty($jsonString) && is_string($jsonString)) {
$postArr = json_decode($jsonString, true);
//发送者openid
$fromUsername = $postArr['FromUserName'];
//内容
$content = $postArr['Content'];
// file_put_contents(__DIR__.'/wechat.log',print_r($content,true),8);
$json_data = '{
"touser":'.$fromUsername.',
"msgtype":"text",
"text":
{
"content":'.$content.'
}
}';
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".$token;
$res = CurlPost($url,$json_data);
var_dump($res);
}
echo "success";
exit;
?>
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/6360.html