getRevPic() public method

获取接收消息图片
public getRevPic ( )
Exemplo n.º 1
0
         msgSend($msgEvent['key']);
     }
     break;
     // 收到文本消息
 // 收到文本消息
 case Wechat::MSGTYPE_TEXT:
     $msgKey = $weObj->getRevContent();
     if (strlen($msgKey) > 20) {
         exit;
     }
     msgSend($msgKey);
     break;
     // 收到图片消息
 // 收到图片消息
 case Wechat::MSGTYPE_IMAGE:
     $msgImage = $weObj->getRevPic();
     // 下载图片
     $fileData = xcurl($msgImage['picurl']);
     if (is_string($fileData) && substr($fileData, 0, 10) === 'curl_error') {
         exit;
     }
     // 写入图片
     $fileFolder = 'wechat-photo/';
     $fileName = date('Ymd-His') . '-' . $weObj->getRevID();
     file_put_contents($fileFolder . $fileName, $fileData);
     $fileInfo = getimagesize($fileFolder . $fileName);
     switch ($fileInfo['mime']) {
         case 'image/jpeg':
             rename($fileFolder . $fileName, $fileFolder . $fileName . '.jpg');
             break;
         case 'image/png':
Exemplo n.º 2
0
<?php

require_once 'config.php';
require_once 'db.php';
require_once 'wechat.class.php';
require_once 'function.php';
include 'emoji.php';
$options = array('token' => WX_TOKEN, 'appid' => WX_APPID, 'encodingaeskey' => WX_KEY, 'appsecret' => WX_SECRET);
$weObj = new Wechat($options);
$weObj->valid();
$redirectURI = urlencode("http://" . WX_URL . "/main.php");
$authURI = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . WX_APPID . "&redirect_uri=" . $redirectURI . "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
$type = $weObj->getRev()->getRevType();
switch ($type) {
    case Wechat::MSGTYPE_IMAGE:
        $pic = $weObj->getRevPic();
        $db = new DB();
        $db->connect();
        $userInfo = $db->getInfo($weObj->getRevFrom());
        if ($userInfo['state'] != 0) {
            $weObj->text("你已经通过认证!")->reply();
        } else {
            $db->postImg($weObj->getRevFrom(), $pic['mediaid']);
            if ($userInfo['pic']) {
                $weObj->text("成功修改证件照片!")->reply();
            } else {
                $weObj->text("成功录入证件照片!\n再次提交即可修改")->reply();
            }
        }
        $db->disconnect();
        break;