本文整理匯總了PHP中Wechat::getRevFrom方法的典型用法代碼示例。如果您正苦於以下問題:PHP Wechat::getRevFrom方法的具體用法?PHP Wechat::getRevFrom怎麽用?PHP Wechat::getRevFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Wechat
的用法示例。
在下文中一共展示了Wechat::getRevFrom方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: switch
switch ($revEvent['event']) {
case "subscribe":
$wechatObj->text("歡迎您關注福大人,我們會用心為您服務。\n目前您可以使用的功能有:\n我的圖書館:發送: ”我的圖書館“指令查看\n\n如果您閑來無聊,可以試試和福大人小機器人聊天哦。\n 福大人工作室" . "")->reply();
break;
case "unsubscribe":
break;
}
break;
case Wechat::MSGTYPE_IMAGE:
$newsData = array(0 => array('Title' => '歡迎您關注福大人', 'Description' => "歡迎您關注福大人,我們會用心為您服務。\n\n 福大人工作室", 'PicUrl' => 'http://com/weixin//static/images/fzu.gif', 'Url' => 'http://r.com/weixin//info.html'));
$wechatObj->news($newsData)->reply();
break;
case Wechat::MSGTYPE_LOCATION:
$revGeo = $wechatObj->getRevGeo();
if ($revGeo) {
$wechatObj->text("您的位置信息是:X=" . $revGeo['x'] . ",Y=" . $revGeo['y'] . "\n" . $revGeo['label'])->reply();
}
break;
case Wechat::MSGTYPE_VOICE:
//多媒體消息關聯獲取id,並下載文件到服務器本地示例
$oneMessage = $wechatObj->getOneMessage($wechatObj->getRevCtime(), $wechatObj->getRevType(), $wechatObj->getRevFrom());
$mediaFile = array();
if ($oneMessage) {
$mediaFile = $wechatObj->getDownloadFile($oneMessage["id"]);
}
// $wechatObj->text(serialize($mediaFile))->reply();
$wechatObj->text($oneMessage ? "消息id:{$oneMessage['id']}\n類型:{$oneMessage['type']}\nLO時間戳:" . $wechatObj->getRevCtime() . "\nMP時間戳:{$oneMessage['dateTime']}\n文件路徑:{$mediaFile['filename']}\n文件大小:{$mediaFile['filesize']}\n文件類型:{$mediaFile['filetype']}" : "獲取失敗\nLO時間戳:" . $wechatObj->getRevCtime() . print_r($oneMessage, TRUE))->reply();
break;
default:
$wechatObj->text("help info")->reply();
}
示例2: Wechat
$w = new Wechat($options);
$w->valid();
$type = $w->getRev()->getRevType();
switch ($type) {
case Wechat::MSGTYPE_TEXT:
$w->text("感謝您的留言,稍後回複您!")->reply();
break;
case Wechat::MSGTYPE_EVENT:
$result = $w->getRevEvent();
switch ($result['event']) {
case 'subscribe':
if ($w->getRevSceneId()) {
//0.將該掃描事件寫入數據庫,掃描時間,用戶id,
$postScanurl = $apiUrl . "/postScan." . $apiSuffix;
//寫入掃描時間的api @post
$param = array('wechatId' => $w->getRevFrom(), 'createAt' => $w->getRevCtime(), 'stationId' => $w->getRevSceneId(), 'status' => 0);
http_post($postScanurl, $param);
//1.檢查數據庫是否有該用戶
$getUserinfoUrl = $apiUrl . "/getUserinfo." . $apiSuffix . "?wechatId=" . $w->getRevFrom();
$userinfo = json_decode(http_get($getUserinfoUrl));
//2.如果有,查詢該用戶是否有借車行為
if ($userinfo->status == "0") {
//@get
$userLendUrl = $apiUrl . "/userLend." . $apiSuffix . "?userId=" . $userinfo->info->userId . "&lendStatus=0";
$userLend = json_decode(http_get($userLendUrl));
//3.如果2的結果是有,提示:XX請在3分鍾內點擊下方還車按鈕進行還車
if ($userLend->status == "0") {
$lendtips = "尊敬的用戶" . $userinfo->info->wechatName . ",您已借車,請在3分鍾內點擊下方的還車按鈕進行還車" . $userlend->status;
$w->text($lendtips)->reply();
} else {
if ($userLend->status == "102") {
示例3: array
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;
case Wechat::MSGTYPE_TEXT:
$weObj->text("你好,歡迎來到imall 公益電商平台 和" . WX_TITLE . " 校園公共自行車服務!\n\n<a href='http://www.imall365.org'>點此開始imall公益電商之旅!</a>\n<a href='" . $authURI . "'>點此開始你的" . WX_TITLE . "!</a>")->reply();
break;
示例4: Wechat
* @version 1.0
*/
include "wechat.class.php";
$options = array
(
'token'=>'weego',
'debug'=>true,
'logcallback'=>'logdebug'
);
$weObj = new Wechat($options);
// 驗證
$weObj->valid();
// 獲取內容
$weObj->getRev();
// 獲取用戶的OpenID
$fromUsername = $weObj->getRevFrom();
// 獲取接受信息的類型
$type = $weObj->getRev()->getRevType();
//**********關注操作則寫入數據庫**********/
if($weObj->getRevSubscribe())
{
// 獲取用戶OPENID並寫入數據庫
$mysql = new SaeMysql();
$sql = "INSERT INTO `users` (`wxid`) VALUES ('" . $fromUsername . "');";
$mysql->runSql($sql);
$mysql->closeDb();
// 獲得信息的類型
$news = array
(
array