6 Star 3 Fork 4

天择网络/天择云商

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
notify_url.php 3.20 KB
一键复制 编辑 原始数据 按行查看 历史
[email protected] 提交于 2018-01-31 14:12 . 权限修改
<?php
header("Content-type:text/html;charset=utf-8");
require_once '../vendor/autoload.php';
/**
* Created by PhpStorm
* @Date: 2017/7/13
* @Time: 10:59
* @Author: eRic
* @Email: [email protected]
* @File: notify_url.php
*/
// 第三方发送消息给公众平台
include_once "../application/third_party/Dsanfang-php-msg/wxBizMsgCrypt.php";
use EasyWeChat\Foundation\Application;
use EasyWeChat\Message\Text;
use EasyWeChat\Staff\Staff;
$options = [
'mini_program' => [
'app_id' => 'wx303239e774ece00c',
'secret' => 'b346a5a6c7633c4518b126ec8ec0ef9a',
// token 和 aes_key 开启消息推送后可见
'token' => 'ZuODgDbE0yn2iZ5cr5gEddkK',
'aes_key' => 'BxC7mexFZuODgDbE0yn2iZ5cr5gEddkKvHxSqzwyeYG'
],
];
$encrypt2_data = file_get_contents ( 'php://input' );
error_log(print_r(array("encrypt2_data" => $encrypt2_data),true),3,'log.txt');
$evtk = '';
$app = new Application($options);
$staff = $app->staff; // 客服管理
$message = new Text(['content' => 'Hello world!']);
$openId = "oYaHv0L1F8IwfZ_bHyTmo08Rqpns";
$result = $staff->message($message)->to($openId)->send();
error_log(print_r(array("消息" => $result),true),3,'log.txt');
echo "success";
exit;
/*$server = $app->server;
$server->setMessageHandler(function($message){
// 注意,这里的 $message 不仅仅是用户发来的消息,也可能是事件
// 当 $message->MsgType 为 event 时为事件
if ($message->MsgType == 'event') {
$evtk = $message->Event;
}
});*/
exit;
$encodingAesKey = "BxC7mexFZuODgDbE0yn2iZ5cr5gEddkKvHxSqzwyeYG";
$token = "ZuODgDbE0yn2iZ5cr5gEddkK";
$timeStamp = time();
$nonce = "2343".time();
$appId = "wx303239e774ece00c";
$text = "<xml><ToUserName><![CDATA[oia2Tj我是中文jewbmiOUlr6X-1crbLOvLw]]></ToUserName><FromUserName><![CDATA[gh_7f083739789a]]></FromUserName><CreateTime>1407743423</CreateTime><MsgType><![CDATA[video]]></MsgType><Video><MediaId><![CDATA[eYJ1MbwPRJtOvIEabaxHs7TX2D-HV71s79GUxqdUkjm6Gs2Ed1KF3ulAOA9H1xG0]]></MediaId><Title><![CDATA[testCallBackReplyVideo]]></Title><Description><![CDATA[testCallBackReplyVideo]]></Description></Video></xml>";
$pc = new WXBizMsgCrypt($token, $encodingAesKey, $appId);
$encryptMsg = '';
$errCode = $pc->encryptMsg($text, $timeStamp, $nonce, $encryptMsg);
if ($errCode == 0) {
//print("加密后: " . $encryptMsg . "\n");
} else {
//print($errCode . "\n");
}
$xml_tree = new DOMDocument();
$xml_tree->loadXML($encryptMsg);
$array_e = $xml_tree->getElementsByTagName('Encrypt');
$array_s = $xml_tree->getElementsByTagName('MsgSignature');
$encrypt = $array_e->item(0)->nodeValue;
$msg_sign = $array_s->item(0)->nodeValue;
$format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>";
$from_xml = sprintf($format, $encrypt);
// 第三方收到公众号平台发送的消息
//$msg = "123456";
$errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg);
if ($errCode == 0) {
//print("解密后: " . $msg . "\n");
} else {
//print($errCode . "\n");
}
$_REQUEST['msg'] = $msg;
$_REQUEST['errCode'] = $errCode;
$_REQUEST['evtk'] = $evtk;
$_REQUEST['encryptMsg'] =$encryptMsg;
error_log(print_r($_REQUEST,true),3,'log.txt');
//echo "123";
echo "success";
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/TianZeWangLuo/TianZeYunShang.git
[email protected]:TianZeWangLuo/TianZeYunShang.git
TianZeWangLuo
TianZeYunShang
天择云商
master

搜索帮助