當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。