dever 6 سال پیش
والد
کامیت
474baa6541
1فایلهای تغییر یافته به همراه102 افزوده شده و 0 حذف شده
  1. 102 0
      component/service/Auth.php

+ 102 - 0
component/service/Auth.php

@@ -0,0 +1,102 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| receive.php 用于接收微信发过来的信息
+|--------------------------------------------------------------------------
+*/
+namespace Component\Service;
+
+use Dever;
+use Main\Lib\Wechat;
+
+class Auth
+{
+	const TYPE = 5;
+
+	/**
+	 * wechat
+	 *
+	 * @var Wechat
+	 */
+	private $wechat;
+	
+	/**
+	 * result
+	 *
+	 * @var array
+	 */
+	private $result;
+	
+	/**
+	 * output
+	 *
+	 * @var string
+	 */
+	private $output;
+	
+	/**
+     * 构造函数 初始化
+     * 
+     * @return mixed
+     */
+	public function __construct()
+	{
+		
+	}
+	
+	/**
+     * 业务推送接口 微信服务器会将所有请求都推送到这里
+     * 
+     * @return mixed
+     */
+	public function main()
+	{
+		$this->output = '';
+		
+		# 获取微信消息
+		$this->request();
+		
+		# 对消息进行验证,并根据类型得到本平台的配置数据
+		//$this->response();
+		
+		# 输出
+		$this->output();
+	}
+	
+	/**
+     * 输出
+     * 
+     * @return mixed
+     */
+	private function output()
+	{
+		if (!$this->output) {
+			$this->output = 'success';
+		}
+		echo $this->output;die;
+	}
+
+    /**
+     * 获取微信发送的内容
+     * 
+     * @return mixed
+     */
+    private function request()
+    {
+		//$post = $_GET ? $_GET : $_POST;
+		$post = file_get_contents('php://input');
+		
+		Dever::log(time());
+		if (!empty($post)) {
+			$post = json_encode($post);
+			Dever::log($post);
+			return;
+			libxml_disable_entity_loader(true);
+          	$result = (array) simplexml_load_string($post, 'SimpleXMLElement', LIBXML_NOCDATA);
+
+          	$this->handle($result);
+		} else {
+			return false;
+		}
+    }
+}