當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Wechat::news方法代碼示例

本文整理匯總了PHP中Wechat::news方法的典型用法代碼示例。如果您正苦於以下問題:PHP Wechat::news方法的具體用法?PHP Wechat::news怎麽用?PHP Wechat::news使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Wechat的用法示例。


在下文中一共展示了Wechat::news方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: switch

$result = $weObj->createMenu($newmenu);
$type = $weObj->getRev()->getRevType();
$revfrom = $weObj->getRev()->getRevFrom();
$getrevto = $weObj->getRev()->getRevTo();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $msg = $weObj->getRev()->getRevContent();
        switch ($msg) {
            case 'openid':
                //get openid
                $openid = $weObj->getRev()->getRevFrom();
                $weObj->text('openid:' . $openid)->reply();
                break;
            case '預約查詢':
                $newsData = array($item = array('Title' => '預約查詢', 'Description' => '點擊查看', 'Url' => 'www.blkqyy.com/admin.php/message/add_yuyue.html?weixin_id=' . $topmsg['fakeid']));
                $weObj->news($newsData)->reply();
                break;
            default:
                $weObj->text("您的消息我們已經收到,感謝您的支持!")->reply();
                break;
        }
        exit;
        break;
        // 接收語音消息
    // 接收語音消息
    case Wechat::MSGTYPE_VOICE:
        $voice = $weObj->getRevVoice();
        $weObj->voice($voice['mediaid'])->reply();
        exit;
        break;
    case Wechat::MSGTYPE_EVENT:
開發者ID:dlpc,項目名稱:weixin_php_sdk,代碼行數:31,代碼來源:demo.php

示例3: openlog

    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:
        $event = $recv->getRevEvent();
        $message = array("0" => array("Title" => "GDS攜雲災備方案參加第十屆災備論壇 助力大數據價值挖掘", "Description" => "GDS攜雲災備方案參加第十屆災備論壇 助力大數據價值挖掘", "Url" => "http://www.gds-services.com/new_1787.html", "PicUrl" => "http://www.gds-services.com/upload/articles/1434592478.jpg"), "1" => array("Title" => "Bash漏洞爆發,GDS迅速應對", "Description" => "Bash漏洞爆發,GDS迅速應對", "Url" => "http://www.gds-services.com/new_1757.html", "PicUrl" => "http://www.gds-services.com/images/imgc-1.png"));
        $weObj->news($message)->reply();
        break;
    default:
        $weObj->text("other info" . var_export($recv, true))->reply();
}
開發者ID:adexbn,項目名稱:gds_wechat,代碼行數:31,代碼來源:index.php

示例4: array

<?php

include "wechat.class.php";
include "./controller/textController/TextController.php";
include "./controller/eventController/EventController.php";
include "./model/TextModel.php";
include "./model/EventModel.php";
include "./config/params.php";
$options = array('token' => '', 'encodingaeskey' => '', 'appid' => '', 'appsecret' => '');
$weObj = new Wechat($options);
$weObj->valid();
$type = $weObj->getRev()->getRevType();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $textObj = new TextController($weObj);
        $reply = $textObj->replyIndex();
        $weObj->text($reply)->reply();
        break;
    case Wechat::MSGTYPE_EVENT:
        $eventObj = new EventController($weObj);
        $reply = $eventObj->replyIndex();
        //$weObj->text($reply)->reply();
        $weObj->news($reply)->reply();
        break;
    case Wechat::MSGTYPE_IMAGE:
        break;
    default:
        $weObj->text("help info")->reply();
}
開發者ID:emonmit,項目名稱:shikun.wang-wechat-gsjl,代碼行數:29,代碼來源:gsjlx.php

示例5: array

     }
     break;
 case Wechat::MSGTYPE_EVENT:
     $revEvent = array();
     $revEvent = $wechatObj->getRevEvent();
     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();
開發者ID:laahii,項目名稱:Wechat-php,代碼行數:31,代碼來源:wechat.php

示例6: array

include "wechat.class.php";
$options = array('token' => 'vonvon', 'encodingaeskey' => 'encodingaeskey', 'appid' => 'wx519f23f4a45e8c37', 'appsecret' => 'ea8f0b17b3a0882bf5fda7ed27758482');
$weObj = new Wechat($options);
$weObj->valid();
//明文或兼容模式可以在接口驗證通過後注釋此句,但加密模式一定不能注釋,否則會驗證失敗
$openid = $weObj->getRev()->getRevFrom();
$token = $weObj->checkAuth();
$info = $weObj->getUserInfo($openid);
$type = $weObj->getRev()->getRevType();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $content = $weObj->getRev()->getRevContent();
        if (substr($content, 0, 6) == '姓名') {
            $name = substr($content, 6);
            $res = array("0" => array('Title' => $name . ', 你的生辰八字', 'Description' => 'Vonvon作為國際化的SNS社交媒體,從2015年1月起,在全世界已經擁有1億以上的 用戶。現在已在韓國,中國,台灣,泰國,越南,印尼,美國,巴西,西班牙等國家 開放。將來會拓展到更多的國家,並且會創作更多有趣的主題測試。', 'PicUrl' => 'http://cdn-cn-static-dr.vonvon.net/images/cn/recruit_main.jpg', 'Url' => 'http://cn.vonvon.net/'));
            $weObj->news($res)->reply();
        } else {
            $weObj->text("Your nickname is " . $info['nickname'] . "\nYour sex is " . $info['sex'] . "\nYour city is " . $info['city'] . "\nYour province is " . $info['province'] . "\n Your country is " . $info['country'] . "\nYour headimgurl is " . $info['headimgurl'] . "\nYour subscribe_time is " . date("Y-m-d H:i:s", $info['subscribe_time']) . "\nNow is " . date("Y-m-d H:i:s", time()))->reply();
            exit;
        }
        break;
    case Wechat::MSGTYPE_EVENT:
        $event = $weObj->getRev()->getRevEvent();
        switch ($event['event']) {
            case 'subscribe':
                $subscribe = array("0" => array('Title' => $info['nickname'] . ', welcome to VonVon!', 'Description' => 'Vonvon作為國際化的SNS社交媒體,從2015年1月起,在全世界已經擁有1億以上的 用戶。現在已在韓國,中國,台灣,泰國,越南,印尼,美國,巴西,西班牙等國家 開放。將來會拓展到更多的國家,並且會創作更多有趣的主題測試。', 'PicUrl' => 'http://cdn-cn-static-dr.vonvon.net/images/cn/recruit_main.jpg', 'Url' => 'http://cn.vonvon.net/'), "1" => array('Title' => '盜墓筆記測試——你是南派還是北派', 'Description' => '你看過盜墓筆記嗎?你知道盜墓人士中分南派和北派嗎?來測一下你是屬於什麽派的吧?', 'PicUrl' => 'http://cdn-cn.vonvon.net/vonvon-cn-real/editor/1436839209469-SArBr8o9DJoXcpLx.jpg', 'Url' => 'http://cn.vonvon.net/quiz/424'));
                $weObj->news($subscribe)->reply();
                break;
            case 'CLICK':
                switch ($event['key']) {
                    case 'god':
開發者ID:shengnwen,項目名稱:vonvonWX,代碼行數:31,代碼來源:index.php

示例7: SaeMysql

    // 獲取用戶OPENID並寫入數據庫
    $mysql = new SaeMysql();
    $sql = "INSERT INTO `users` (`wxid`) VALUES ('" . $fromUsername . "');";
    $mysql->runSql($sql);
    $mysql->closeDb();
    // 獲得信息的類型
    $news = array
    (
        array
        (
            'Title'=>'歡迎關注WeeGo工作室',
            'Description'=>'發送任意內容查看最新開發進展',
            'PicUrl'=>'http://233.weego.sinaapp.com/images/weego_400_200.png',
        )
    );
    $weObj->news($news)->reply();
}
//**********取消關注操作則刪除數據庫**********/
if($weObj->getRevUnsubscribe())
{
    // 獲取用戶OPENID並從數據庫刪除
    $mysql = new SaeMysql();
    $sql = "DELETE FROM `users` WHERE `wxid` = '" . $fromUsername . "'";
    $mysql->runSql($sql);
    $mysql->closeDb();
}
switch($type) {
    case Wechat::MSGTYPE_TEXT:
        /**********文字信息**********/
        $news = array
        (
開發者ID:xupnge1314,項目名稱:sscpms,代碼行數:31,代碼來源:接口對應的index.php文件處理微信服務器發送來的信息.php


注:本文中的Wechat::news方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。