当前位置: 首页>>代码示例>>PHP>>正文


PHP Wechat::valid方法代码示例

本文整理汇总了PHP中Wechat::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::valid方法的具体用法?PHP Wechat::valid怎么用?PHP Wechat::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wechat的用法示例。


在下文中一共展示了Wechat::valid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     import("@.ORG.Weixin");
     $config = $this->Config;
     $wxconfig = F("wxconfig");
     $user = M("user");
     $data = array();
     $wechatObj = new Wechat();
     if ($wxconfig["wstatu"] != "") {
         $data = $wechatObj->responseMsg($idx);
         //接收到的
         $me = $data['me'];
         $guest = $data['user'];
         //////////////////////*用户打入库-开始*///////////////
         $this->adduser($guest);
         if ($data['key'] == "ewm") {
             $ewm = $wechatObj->ewm(2, 1);
             $wechatObj->sendtext($guest, $me, $ewm);
         }
         $wechatObj->sendtext($guest, $me, $guest);
         exit;
         ///////////////////////////////事件开始/////////////////////////
         if ($data['type'] == "event") {
             //关注
             if ($data['event'] == "subscribe" || $data['event'] == "SCAN") {
                 if ($data['key'] == 1) {
                     $user = M("user")->where("wxid='" . sysmd5($guest) . "'")->setfield('vip', 1);
                     $map1['url'] = "http://mall.bydauto.com.cn/echo/index/store";
                     $map1['title'] = "vip会议标题['待定..']";
                     $map1['description'] = "描述的文字['待定..'],点击进去的链接待定,下面的图片大小700x400";
                     $map1['thumb'] = "http://byd.gzqizhen.com/Public/byd/byd.jpg";
                     $wechatObj->sendimg($guest, $me, $map1);
                     exit;
                 }
                 if ($data['key'] == 2) {
                     $vip = M("user")->where("wxid='" . sysmd5($guest) . "'")->getfield('vip');
                     if (!$vip) {
                         $user = M("user")->where("wxid='" . sysmd5($guest) . "'")->setfield('vip', 2);
                     }
                     $map2['url'] = "http://mall.bydauto.com.cn/echo/index/store";
                     $map2['title'] = "新能源['待定..']";
                     $map2['description'] = "描述的文字['待定..']下面的图片大小700x400";
                     $map2['thumb'] = "http://byd.gzqizhen.com/Public/byd/byd.jpg";
                     $wechatObj->sendimg($guest, $me, $map2);
                     // $wechatObj->sendtext($guest,$me,"新能源");
                     exit;
                 }
             }
         }
         ///////////////////////////////事件结束/////////////////////////
         $wechatObj->sendimg($guest, $me, $wxconfig);
     } else {
         M("config")->where("varname='wstatu'")->setField('value', "清理此位置可以重新设置微信接入!");
         $wechatObj->valid($wxconfig["token"]);
         savecache("Config");
     }
 }
开发者ID:anywn3773,项目名称:gzqz,代码行数:57,代码来源:IndexAction.class.php

示例2: index

 public function index()
 {
     import('Vendor.Wechat.Wechat');
     $option = array('token' => 'weixin', 'appid' => 'wx444c22311a33b40d', 'secret' => 'f39ae15e9d86c293edbff26a9c47af6e');
     $wechatObj = new \Wechat($option);
     $wechatObj->valid();
     //解析来向XML
     $msg = $wechatObj->getRev();
     $message['fromUsername'] = $msg->getRevFrom();
     $message['toUsername'] = $msg->getRevTo();
     $message['type'] = $msg->getRevType();
     $message['createtime'] = $msg->getRevCtime();
     $message['keyword'] = $msg->getRevContent();
     $message['event'] = $msg->getRevEvent();
     //保存新用户相关信息
     $status = D('Member');
     $status->InsertNewer($message['fromUsername']);
     //主要部分,暂时仅使用TEXT,EVENT两种
     switch ($message['type']) {
         case $wechatObj::MSGTYPE_TEXT:
             $text = A('Text');
             $ret = $text->textSkip($message);
             if ('text' == $ret['type']) {
                 $wechatObj->text($ret['content'])->reply();
             } else {
                 if ('news' == $ret['type']) {
                     $wechatObj->news($ret['content'])->reply();
                 }
             }
             break;
         case $wechatObj::MSGTYPE_EVENT:
             $event = A('Event');
             $ret = $event->eventSkip($message);
             if ('text' == $ret['type']) {
                 $wechatObj->text($ret['content'])->reply();
             } else {
                 if ('news' == $ret['type']) {
                     $wechatObj->news($ret['content'])->reply();
                 }
             }
             break;
         default:
             $wechatObj->text('更多功能正在研发中,敬请期待')->reply();
     }
     //获取菜单
     $menu = $wechatObj->getMenu();
     //创建菜单
     $newmenu = array('小瓜神力' => array(array('type' => 'click', 'name' => '新生专题', 'key' => 'V1001_01_01'), array('type' => 'click', 'name' => '校车时刻', 'key' => 'V1001_01_02'), array('type' => 'click', 'name' => '交通导航', 'key' => 'V1001_01_03'), array('type' => 'click', 'name' => '考试成绩', 'key' => 'V1001_01_04'), array('type' => 'click', 'name' => '图书信息', 'key' => 'V1001_01_05')), '军训专题' => array(array('type' => 'click', 'name' => '通知公告', 'key' => 'V1001_02_01'), array('type' => 'click', 'name' => '军训快报', 'key' => 'V1001_02_02'), array('type' => 'click', 'name' => '军营风采', 'key' => 'V1001_02_03'), array('type' => 'view', 'name' => '军歌嘹亮', 'url' => 'http://mp.weixin.qq.com/s?__biz=MjM5OTIxMTM2Mg==&mid=209183345&idx=1&sn=96c4cf9ad618e5e051167456210d9fe8&scene=5&srcid=OJ8qMfaW9nS5T0jFFjQj#rd'), array('type' => 'click', 'name' => '微军训', 'key' => 'V1001_02_05')), '小瓜威武' => array(array('type' => 'click', 'name' => '小瓜在线', 'key' => 'V1001_03_01'), array('type' => 'click', 'name' => '跑操查询', 'key' => 'V1001_03_02'), array('type' => 'view', 'name' => '瓜棚论坛', 'url' => 'http://npuxiaogua.mgschool.cn/wx/apps/liuyan/'), array('type' => 'view', 'name' => '失物招领', 'url' => 'http://npuxiaogua.mgschool.cn/wx/npuxg_blog/wxq/index.php'), array('type' => 'click', 'name' => '表白墙', 'key' => 'V1001_03_05')));
     $result = $wechatObj->createMenu($newmenu);
 }
开发者ID:partholon,项目名称:xiaogua,代码行数:50,代码来源:IndexController.class.php

示例3: index

 public function index()
 {
     import("@.ORG.Weixin");
     $config = $this->Config;
     $wxconfig = F("wxconfig");
     $user = M("user");
     $data = array();
     $wechatObj = new Wechat();
     if ($wxconfig["wstatu"] != "") {
         $data = $wechatObj->responseMsg($idx);
         //接收到的
         $me = $data['me'];
         $guest = $data['user'];
         //////////////////////*用户打入库-开始*///////////////
         $this->adduser($guest);
         ///////////////////////////////事件结束/////////////////////////
         $wechatObj->sendimg($guest, $me, $wxconfig);
     } else {
         M("config")->where("varname='wstatu'")->setField('value', "清理此位置可以重新设置微信接入!");
         $wechatObj->valid($wxconfig["token"]);
         savecache("Config");
     }
 }
开发者ID:anywn3773,项目名称:bydproject,代码行数:23,代码来源:IndexAction.class.php

示例4: conn

require_once './config.php';
require_once './class/conn.class.php';
require_once './class/wechat.class.php';
include './include/function.php';
header('Content-type:text/html;charset=utf-8');
const ALREADY_BINDED = '你已经绑定过了';
const HELP = '支持的命令: 状态 , 查询@关键字 , 最新 , 热门';
$user_ptid = -1;
$operation = 'NULL';
$text = '';
$keyword = '';
$user_openid = '';
$con = new conn();
$weObj = new Wechat($wechat_options);
$weObj->valid();
$msg = $weObj->getRev()->getRevData();
//获取用户发送的消息
$user_openid = $weObj->getRev()->getRevFrom();
//获取用户openid
$user_openid = $con->mres($user_openid);
$msg = trim($msg['Content']);
switch ($msg) {
    case '绑定':
        $operation = BIND;
        break;
    case '状态':
        $operation = STATUS;
        break;
    case '热门':
        $operation = HOT;
开发者ID:Qbuer,项目名称:pt-wechat,代码行数:30,代码来源:index.php

示例5: reply_main

define("YOURNICK", "广药小助手");
// 在这里定义你的初次关注后的欢迎语和菜单@title|【网站导航】-
define("WELCOME", "欢迎关注广药小助手!\n直接回复?或者help即可出现菜单");
define("MENU", "description|菜单#title|功能向导@title|【校园资讯】- 回复数字或提示\n\n[1]广药新闻\t\t[2]就业信息\n[3]图书信息\t\t[4]还书\n[5]动漫更新\t\t[6]交通卡余额\n[7]查课表\t\t\t\t[8]发找找帮\n[9]勤管兼职\t\t[10]查成绩\n[11]查选修\t\t\t[cet]查四六级\n[开]开户指南\t[意见]给小助手提意见\n[绑定]绑定学号密码#url|#pic@title|【生活服务】-回复字母\n\n[A]听歌\t[B]公交\t[C]翻译\t[D]快递\n[E]解梦\t[F]手机\t[G]身份\t[H]音乐\n[T]天气#url|#pic@title|\t聊天:任意回复\t\t提意见?回复意见#url|#pic@title|合作事宜:回复 合作 或 推送#url|#pic@title|上不了校园网?网络有故障?\n点击进入查询故障解决方案==>>#url|http://av.jejeso.com/Ours/911/index.php#pic@title| CopyRight By OURStudio#url|#pic");
define("TEXT", "【校园资讯-回复数字或提示】\n[1]广药新闻\t[2]就业信息\n[3]图书信息\t[cet]查四六级\n[5]动漫更新\t[6]交通卡余额\n[7]查课表\t[8]发找找帮\n[9]勤管兼职\t[10]查成绩\n[11]查选修\t[开]开户指南\n\n【生活服务-回复字母】\n[A]听歌\t[B]公交\t[C]翻译\t[D]快递\n[E]解梦\t[F]手机\t[G]身份\t[H]音乐\t\n[T]天气\n聊天: 任意回复\t\t提意见?回复意见\n\n上不了校园网?回复:校园网故障查询 或者 报障 或者 114.w\n\n合作事宜: 回复 合作 或 推送");
// 星标标识,默认为* ,用户对话里包含此标识则设置为星标,用于留言
define("FLAG", "*");
// 这里为你的私有库账号
$yourdb = "gdpuer";
$yourpw = "ourstudio";
$welcome = '欢迎关注广药小助手';
// 配置结束
$w = new Wechat(TOKEN, DEBUG);
// 首次验证,验证过以后可以删掉
if (isset($_GET['echostr'])) {
    $w->valid();
    exit;
}
// 回复用户
$w->reply("reply_main");
// 后续必要的处理...
/* TODO */
exit;
function reply_main($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    // 大众接口
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
开发者ID:YongHaoWu,项目名称:gdpuer,代码行数:31,代码来源:index.php

示例6: _log

<?php

include './qy-sdk/qywechat.class.php';
function _log($text)
{
    //$result = file_put_contents('wechat.log.'.date('Y-m-d'), $text."\n", FILE_APPEND);
    //if (!$result) {
    openlog("wechat", LOG_PID | LOG_PERROR, LOG_LOCAL0);
    syslog(LOG_DEBUG, $text);
    closelog();
    //}
}
$options = array('token' => 'N6cq3R', 'encodingaeskey' => 'nil3OzTxXoPHx4mvx0GLbyECkPYrfyiB9ca4Iz61ny3', 'appid' => 'wx926454a4965d2b7c', 'appsecret' => 'PkG1V74sWm6V2mNN3F2NOHKQT696g1wrmJZhB7WT-8xcLmt-3rez3FfuH3SzCf', 'agentid' => '3', 'debug' => true, 'logcallback' => '_log');
$weObj = new Wechat($options);
_log("GET参数为:\n" . var_export($_GET, true));
$valid = $weObj->valid();
if (!$valid) {
    _log("验证失败");
    exit($valid);
}
$recv = $weObj->getRev();
$type = $recv->getRevType();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $weObj->text("I got your message, here is <a href=\"http://www.gds-services.com\">gds</a>")->reply();
        exit;
        break;
    case Wechat::MSGTYPE_IMAGE:
        $weObj->text("I got your image")->reply();
        break;
    case Wechat::MSGTYPE_EVENT:
开发者ID:adexbn,项目名称:gds_wechat,代码行数:31,代码来源:index.php

示例7: valid

<?php

//声明一个常量定义一个token值, token
define("TOKEN", "199036");
//通过Wechat类, 创建一个对象
$wechatObj = new Wechat();
//如果没有通过GET收到echostr字符串, 说明不是再使用token验证
if (!isset($_GET['echostr'])) {
    //调用wecat对象中的方法响应用户消息
    $wechatObj->responseMsg();
} else {
    //调用valid()方法,进行token验证
    $wechatObj->valid();
}
//声明一个Wechat的类, 处理接收消息, 接收事件, 响应各种消息, 以及token验证
class Wechat
{
    //验证签名, 手册中原代码改写
    public function valid()
    {
        //在开发者首次提交验证申请时,微信服务器将发送GET请求到填写的URL上,并且带上四个参数(signature、timestamp、nonce、echostr),开发者通过对签名(即signature)的效验,来判断此条消息的真实性。
        $echoStr = $_GET["echostr"];
        // 随机字符串
        $signature = $_GET["signature"];
        //微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
        $timestamp = $_GET["timestamp"];
        //时间戳
        $nonce = $_GET["nonce"];
        // 随机数
        //上面通过常量声明的token值
        $token = TOKEN;
开发者ID:hurongjiang,项目名称:mytest,代码行数:31,代码来源:index.php

示例8: add

 public function add()
 {
     include "./wechat-php-sdk/wechat.class.php";
     $options = array('token' => 'tokenaccesskey');
     $weObj = new Wechat($options);
     $weObj->valid();
     $type = $weObj->getRev()->getRevType();
     switch ($type) {
         case Wechat::MSGTYPE_TEXT:
             $weObj->text("hello, I'm wechat")->reply();
             exit;
             break;
         case Wechat::MSGTYPE_EVENT:
             break;
         case Wechat::MSGTYPE_IMAGE:
             break;
         default:
             $weObj->text("help info")->reply();
     }
 }
开发者ID:huanlanxingduan,项目名称:wechat-activity,代码行数:20,代码来源:ContentAction.class.php

示例9: logg

<?php

include "../qywechat.class.php";
function logg($text)
{
    file_put_contents('./log.txt', $text . "\r\n\r\n", FILE_APPEND);
}
$options = array('token' => '9xxxxxxxxxxxx', 'encodingaeskey' => 'd4oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'appid' => 'wxa0xxxxxxxxxx', 'debug' => true, 'logcallback' => 'logg');
logg("GET参数为:\n" . var_export($_GET, true));
$weObj = new Wechat($options);
$ret = $weObj->valid();
if (!$ret) {
    logg("验证失败!");
    var_dump($ret);
    exit;
}
$f = $weObj->getRev()->getRevFrom();
$t = $weObj->getRevType();
$d = $weObj->getRevData();
$weObj->text("你好!来自星星的:" . $f . "\n你发送的" . $t . "类型信息:\n原始信息如下:\n" . var_export($d, true))->reply();
logg("-----------------------------------------");
开发者ID:congcongbebe,项目名称:wechat-php-sdk,代码行数:21,代码来源:qydemo.php


注:本文中的Wechat::valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。