Ejemplo n.º 1
0
 /**
  * 输出
  *
  * @param \spWxResponse $response
  */
 public static function Output(spWxResponse $response)
 {
     if (isset($_GET['encrypt_type']) && $_GET['encrypt_type']) {
         $output = spWxTransportEncrypted::Output($response);
     } else {
         $output = spWxTransportPlain::Output($response);
     }
     spWxLogger::Log('spWxTransport::Output', ['output' => $output]);
     echo $output;
     exit;
 }
Ejemplo n.º 2
0
 /**
  * Default Exception Handler
  *
  * @param $exception
  */
 public static function ExceptionHandler($exception)
 {
     try {
         throw $exception;
     } catch (Exception $e) {
         if (php_sapi_name() == 'cli') {
             echo $e->getMessage() . '#' . $e->getCode() . "\n";
             exit;
         } else {
             spWxLogger::Log('Exception', ['Message' => $e->getMessage(), 'Code' => $e->getCode()]);
             echo json_encode(['code' => $e->getCode(), 'msg' => $e->getMessage()], JSON_UNESCAPED_UNICODE);
             exit;
         }
     }
 }
Ejemplo n.º 3
0
 public static function Forward($url)
 {
     if (strpos($url, '?')) {
         $url .= '&';
     } else {
         $url .= '?';
     }
     foreach (self::$GET_FIELDS as $f) {
         if (isset($_GET[$f])) {
             $url .= $f . '=' . urlencode($_GET[$f]) . '&';
         }
     }
     $post = spWxTransport::Input();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
     curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type' => $_SERVER['HTTP_CONTENT_TYPE']]);
     $s = curl_exec($ch);
     $i = curl_getinfo($ch);
     curl_close($ch);
     spWxLogger::Log('spWxRequestForwarder', ['url' => $url, 'data' => $post, 'result' => $s, 'info' => $i]);
     return $s;
 }