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


PHP Wechat类代码示例

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


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

示例1: _initialize

 function _initialize()
 {
     parent::_initialize();
     if (!$this->_userid) {
         header("Location: " . U('User/Login/index'));
         exit;
     }
     $this->dao = M('User');
     $this->assign('bcid', 0);
     $user = $this->dao->find($this->_userid);
     if (empty($user["wxpas"])) {
         $himt = "<script type=\"text/javascript\">\$(document).ready(function(){alert(\"你还没绑定微信请扫描二维码绑定!\");});</script>";
         $this->assign("himt", $himt);
     }
     $user["username"] = $user["realname"] != "" ? $user["realname"] . "[" . $user["username"] . "]" : $user["username"];
     //////////////获得绑定二维码
     import("@.ORG.Weixin");
     $wechatObj = new Wechat();
     $user["ticket"] = $wechatObj->ewm($user["id"], 0);
     //////////////获得绑定二维码
     $this->user = $user;
     $this->assign('vo', $user);
     unset($_POST['status']);
     unset($_POST['groupid']);
     unset($_POST['amount']);
     unset($_POST['point']);
     $_GET = get_safe_replace($_GET);
     $order["count"] = M("order")->where(array('status' => 0, 'userid' => $this->_userid))->count();
     $order["all"] = M("order")->where(array('userid' => $this->_userid))->count();
     $order["ok"] = M("order")->where(array('status' => 1, 'userid' => $this->_userid))->count();
     $this->assign('order', $order);
     $this->assign('actionname', ACTION_NAME);
 }
开发者ID:anywn3773,项目名称:gzsrex,代码行数:33,代码来源:IndexAction.class.php

示例2: index

 public function index()
 {
     $thisurl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $rt = explode('index.php', $thisurl);
     $arg = isset($rt[1]) ? $rt[1] : '';
     if (!empty($arg)) {
         $rt = explode('/', $arg);
         $arg = isset($rt[1]) ? $rt[1] : '';
         if (!empty($arg)) {
             $this->token = trim($arg);
         }
     }
     if (!class_exists('SimpleXMLElement')) {
         exit('SimpleXMLElement class not exist');
     }
     if (!function_exists('dom_import_simplexml')) {
         exit('dom_import_simplexml function not exist');
     }
     if (!preg_match("/^[0-9a-zA-Z]{3,42}\$/", $this->token)) {
         exit('error token');
     }
     $weixin = new Wechat($this->token);
     $this->data = $weixin->request();
     if ($this->data) {
         list($content, $type) = $this->reply($this->data);
         $weixin->response($content, $type);
     }
 }
开发者ID:henryxxk,项目名称:wxapi,代码行数:28,代码来源:index.php

示例3: index

 function index()
 {
     if (!session('openid_' . $this->token)) {
         $this->info = M('wxuser')->where(array('token' => $this->token))->find();
         vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor');
         vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor');
         $wechat = new Wechat();
         $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret']));
         $redirect_uri = C('site_url') . '/index.php/Wap/Login/index?token=' . $this->token . '&url=' . $this->url;
         if (!$_GET['code']) {
             // By sending no options it'll come back here
             $url = $wechat->authorize(array('redirect_uri' => $redirect_uri));
             redirect($url);
         } else {
             try {
                 // Have a go at creating an access token from the code
                 $access_token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri));
                 // Use this object to try and get some user details (username, full name, etc)
                 $user = $wechat->get_user_info($access_token);
                 $this->save_wechat_user($user);
                 session('openid_' . $this->token, $user->openid);
             } catch (OAuth2_Exception $e) {
                 print_r($e);
                 die;
             }
         }
     }
     if ($this->url) {
         redirect($this->url);
     }
 }
开发者ID:zhaoshengloveqingqing,项目名称:Wechat,代码行数:31,代码来源:LoginAction.class.php

示例4: index

 public function index()
 {
     if (!class_exists('SimpleXMLElement')) {
         exit('SimpleXMLElement class not exist');
     }
     if (!function_exists('dom_import_simplexml')) {
         exit('dom_import_simplexml function not exist');
     }
     $this->token = $this->_get('token', "htmlspecialchars");
     if (!preg_match("/^[0-9a-zA-Z]{3,42}\$/", $this->token)) {
         exit('error token');
     }
     $weixin = new Wechat($this->token);
     $data = $weixin->request();
     $this->data = $weixin->request();
     $this->fans = S('fans_' . $this->token . '_' . $this->data['FromUserName']);
     if (!$this->fans || 1) {
         $this->fans = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find();
         S('fans_' . $this->token . '_' . $this->data['FromUserName'], $this->fans);
     }
     $this->wxuser = S('wxuser_' . $this->token);
     if (!$this->wxuser || 1) {
         $this->wxuser = D('Wxuser')->where(array('token' => $this->token))->find();
         S('wxuser_' . $this->token, $this->wxuser);
     }
     $this->my = C('site_my');
     $this->apiServer = apiServer::getServerUrl();
     $open = M('Token_open')->where(array('token' => $this->_get('token')))->find();
     $this->fun = $open['queryname'];
     list($content, $type) = $this->reply($data);
     $weixin->response($content, $type);
 }
开发者ID:SubDong,项目名称:pigcms,代码行数:32,代码来源:WeixinAction.class.php

示例5: index

 public function index()
 {
     $this->token = $this->_get('token');
     $this->my = C('site_my');
     #        Log::record('weixinmsg',Log::DEBUG);
     #       Log::record('weixinmsg',$this->token,Log::DEBUG);
     #      Log::save();
     #     $this->siteName = C('site_name');
     $weixin = new Wechat($this->token);
     //$data = $weixin->request();
     //$this->xml = $weixin->xml;
     $this->data = $weixin->request();
     //是否是在上墙中
     if ($this->data) {
         $data = $this->data;
         $users = S($data['FromUserName'] . 'wxq');
         if ($users != false) {
             $res = $this->wxq($users);
         } else {
             $res = $this->reply($data);
         }
         list($content, $type) = $res;
         $weixin->response($content, $type);
     }
 }
开发者ID:yakrsa,项目名称:football,代码行数:25,代码来源:WeixinAction.class.php

示例6: index

 public function index()
 {
     if (!session('openid_' . $this->token)) {
         $this->info = M('wxuser')->where(array('token' => $this->token))->find();
         vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor');
         vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor');
         $wechat = new Wechat();
         $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret']));
         $redirect_uri = C('site_url') . '/index.php/Wap/Coupons/index?token=' . $this->token . '&coupon_id=' . $this->coupon_id;
         if (!$_GET['code']) {
             // By sending no options it'll come back here
             $url = $wechat->authorize(array('redirect_uri' => $redirect_uri));
             redirect($url);
         } else {
             try {
                 // Have a go at creating an access token from the code
                 $token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri));
                 // Use this object to try and get some user details (username, full name, etc)
                 $user = $wechat->get_user_info($token);
                 $this->openid = $user->openid;
                 session('openid_' . $this->token, $user->openid);
             } catch (OAuth2_Exception $e) {
                 print_r($e);
                 die;
             }
         }
     } else {
         $this->openid = session('openid_' . $this->token);
     }
     $url = C('site_url') . "/index.php?g=Wap&m=Coupon&a=index&type=1&token=" . $this->token . '&id=' . $this->coupon_id . '&wecha_id=' . $this->openid;
     header('Location:' . $url);
 }
开发者ID:zhaoshengloveqingqing,项目名称:Wechat,代码行数:32,代码来源:CouponsAction.class.php

示例7: Oauth2

 public function Oauth2()
 {
     if (!session('openid_' . $this->token)) {
         $this->info = M('wxuser')->where(array('token' => $this->token))->find();
         vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor');
         vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor');
         $wechat = new Wechat();
         $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret']));
         $redirect_uri = $_GET['method_name'];
         if (!$_GET['code']) {
             $redirect_uri = C('site_url') . '/index.php/Fxs/Fxs/Oauth2?token=' . $this->token . '&method_name=' . $_GET['method_name'];
             // By sending no options it'll come back here
             $url = $wechat->authorize(array('redirect_uri' => $redirect_uri));
             redirect($url);
         } else {
             try {
                 // Have a go at creating an access token from the code
                 $token = $wechat->access($_GET['code'], array('method_name' => $redirect_uri));
                 // Use this object to try and get some user details (username, full name, etc)
                 $user = $wechat->get_user_info($token);
                 session('openid_' . $this->token, $user->openid);
             } catch (OAuth2_Exception $e) {
                 print_r($e);
                 die;
             }
         }
     }
     if (session('openid_' . $this->token)) {
         $user = M('reguser')->where(array('token' => $this->token, 'openid' => session('openid_' . $this->token)))->find();
         if (!$user) {
             session_destroy();
         }
     }
     header('Location:' . U('Fxs/' . $_GET['method_name'], array('token' => $this->token)));
 }
开发者ID:zhaoshengloveqingqing,项目名称:Wechat,代码行数:35,代码来源:FxsAction.class.php

示例8: updatefeedback

 function updatefeedback()
 {
     $id = $this->_get('id', 'intval');
     header('Content-Type:text/html;charset=utf-8');
     $wetallroute = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
     //dump($wetallroute);exit;
     include $wetallroute . "/wxpay/config.php";
     //dump($config);exit;
     include $wetallroute . "/wxpay/lib.php";
     $wechat = new Wechat();
     // openid 与 feedback参数都可以从数据库中得到
     $feedback = $this->_mod->where(array('id' => $id))->find();
     //dump($feedback);exit;
     //$content = 'http://api.weixin.qq.com/cgi-bin/pay/delivernotify?access_token=' . $wechat->getAccessToken($config) . '&openid=' . $feedback['openid'] . '&feedbackid=' . $feedback['feedbackid'];
     $content = 'https://api.weixin.qq.com/payfeedback/update?access_token=' . $wechat->getAccessToken($config) . '&openid=' . $feedback['openid'] . '&feedbackid=' . $feedback['feedbackid'];
     //dump($content);
     $result = $wechat->curlGet($content);
     //dump($result);exit;
     $result = json_decode($result, true);
     if ($result['errcode'] == 0) {
         //echo 'success';
         //IS_AJAX && $this->ajaxReturn(1, $result['errmsg'], '', 'edit');
         $this->_mod->where(array('id' => $id))->save(array('status' => 1));
         $this->success('通知微信成功!');
     } elseif ($result['errcode'] == -1 && $result['errmsg'] == 'system error') {
         $this->_mod->where(array('id' => $id))->save(array('status' => 1));
         $this->success('已经通知过微信,更改状态成功!');
     } else {
         //IS_AJAX && $this->ajaxReturn(0, $result['errmsg']);
         $this->error($result['errmsg']);
     }
 }
开发者ID:dlpc,项目名称:weixinshop,代码行数:32,代码来源:wxpay_rightsAction.class.php

示例9: send

 function send()
 {
     $u = M("user")->where(array(id => intval($_REQUEST['id'])))->find();
     import("@.ORG.Weixin");
     $wechatObj = new Wechat();
     $data = " {\r\n           \"touser\":\"" . $u['wxpas'] . "\",\r\n           \"template_id\":\"SCFdz1m9pGOO6U-LXp6qv8CUJakT3_Zk-74tjdnK0ok\",\r\n           \"url\":\"http://weixin.qq.com/download\",\r\n           \"topcolor\":\"#FF0000\",\r\n           \"data\":{\r\n                   \"first\": {\r\n                       \"value\":\"恭喜你购买成功!\",\r\n                       \"color\":\"#173177\"\r\n                   },\r\n                   \"keyword1\":{\r\n                       \"value\":\"" . $u['realname'] . "\",\r\n                       \"color\":\"#173177\"\r\n                   },\r\n                   \"keynote2\": {\r\n                       \"value\":\"" . $u['id'] . "产品名称\",\r\n                       \"color\":\"#173177\"\r\n                   },\r\n                   \"keynote3\": {\r\n                       \"value\":\"" . $u['id'] . "\",\r\n                       \"color\":\"#173177\"\r\n                   },\r\n                   \"remark\":{\r\n                       \"value\":\"此订单信息请点击这里查看!!\",\r\n                       \"color\":\"#173177\"\r\n                   }\r\n           }\r\n       }";
     echo $wechatObj->tplmsg($data);
 }
开发者ID:anywn3773,项目名称:gzsrex,代码行数:8,代码来源:UserAction.class.php

示例10: index

 public function index()
 {
     $this->token = 'cmgeshengli';
     $weixin = new \Wechat($this->token);
     $this->data = $weixin->request();
     list($content, $type) = $this->reply($this->data);
     $weixin->response($content, $type);
 }
开发者ID:00606,项目名称:cmge,代码行数:8,代码来源:WeixinController.class.php

示例11: wxoauth

 public function wxoauth()
 {
     $scope = 'snsapi_base';
     $code = isset($_GET['code']) ? $_GET['code'] : '';
     $token_time = isset($_SESSION['token_time']) ? $_SESSION['token_time'] : 0;
     if (!$code && isset($_SESSION['open_id']) && isset($_SESSION['user_token']) && $token_time > time() - 3600) {
         if (!$this->wxuser) {
             $this->wxuser = $_SESSION['wxuser'];
         }
         $this->open_id = $_SESSION['open_id'];
         return $this->open_id;
     } else {
         $options = array('token' => $this->options["token"], 'appid' => $this->options["appid"], 'appsecret' => $this->options["appsecret"]);
         $we_obj = new Wechat($options);
         if ($code) {
             $json = $we_obj->getOauthAccessToken();
             if (!$json) {
                 unset($_SESSION['wx_redirect']);
                 die('获取用户授权失败,请重新确认');
             }
             $_SESSION['open_id'] = $this->open_id = $json["openid"];
             $access_token = $json['access_token'];
             $_SESSION['user_token'] = $access_token;
             $_SESSION['token_time'] = time();
             $userinfo = $we_obj->getUserInfo($this->open_id);
             if ($userinfo && !empty($userinfo['nickname'])) {
                 $this->wxuser = array('open_id' => $this->open_id, 'nickname' => $userinfo['nickname'], 'sex' => intval($userinfo['sex']), 'location' => $userinfo['province'] . '-' . $userinfo['city'], 'avatar' => $userinfo['headimgurl']);
             } elseif (strstr($json['scope'], 'snsapi_userinfo') !== false) {
                 $userinfo = $we_obj->getOauthUserinfo($access_token, $this->open_id);
                 if ($userinfo && !empty($userinfo['nickname'])) {
                     $this->wxuser = array('open_id' => $this->open_id, 'nickname' => $userinfo['nickname'], 'sex' => intval($userinfo['sex']), 'location' => $userinfo['province'] . '-' . $userinfo['city'], 'avatar' => $userinfo['headimgurl']);
                 } else {
                     return $this->open_id;
                 }
             }
             if ($this->wxuser) {
                 $_SESSION['wxuser'] = $this->wxuser;
                 $_SESSION['open_id'] = $json["openid"];
                 unset($_SESSION['wx_redirect']);
                 return $this->open_id;
             }
             $scope = 'snsapi_userinfo';
         }
         if ($scope == 'snsapi_base') {
             $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
             $_SESSION['wx_redirect'] = $url;
         } else {
             $url = $_SESSION['wx_redirect'];
         }
         if (!$url) {
             unset($_SESSION['wx_redirect']);
             die('获取用户授权失败');
         }
         $oauth_url = $we_obj->getOauthRedirect($url, "wxbase", $scope);
         header('Location: ' . $oauth_url);
     }
 }
开发者ID:pinghu1,项目名称:wechat-php-sdk,代码行数:57,代码来源:auth.php

示例12: __construct

 public function __construct(Wechat $wechat)
 {
     $this->content = $wechat->getRev()->getRevContent();
     $this->sender = $wechat->getRev()->getRevFrom();
     $this->create_time = $wechat->getRev()->getRevCtime();
     $this->msg_id = $wechat->getRev()->getRevID();
     $this->models = new TextModel();
     $this->models->actionIndex($this->content, $this->sender, $this->msg_id);
 }
开发者ID:emonmit,项目名称:shikun.wang-wechat-gsjl,代码行数:9,代码来源:TextController.php

示例13: index

 public function index()
 {
     $this->token = $this->_get('token');
     $weixin = new Wechat($this->token);
     $data = $weixin->request();
     $this->data = $weixin->request();
     $this->my = C('site_my');
     list($content, $type) = $this->reply($data);
     $weixin->response($content, $type);
 }
开发者ID:dlpc,项目名称:wxshoppingmall,代码行数:10,代码来源:WeixinAction.class.php

示例14: send_wechat_msg_pe

function send_wechat_msg_pe($staff_openid, $template_id, $url_ticket_id, $first_data, $remark_data, $keyword1_data, $keyword2_data, $keyword3_data = null)
{
    $notice_data = ["touser" => $staff_openid, "template_id" => $template_id, "url" => "https://wechat.gds-services.com/static/html/query_req_detail.html?tid=" . $url_ticket_id, "topcolor" => "#000", "data" => ["first" => ["value" => $first_data, "color" => "#000"], "remark" => ["value" => $remark_data, "color" => "#000"], "keyword1" => ["value" => $keyword1_data, "color" => "#000"], "keyword2" => ["value" => $keyword2_data, "color" => "#000"]]];
    if (!empty($keyword3_data) && $keyword3_data != null) {
        $notice_data->data->keyword3 = ["value" => $keyword3_data, "color" => "#000"];
    }
    $options = ['token' => 'nizhidaoma', 'encodingaeskey' => 'IXR7m0K8Q7KOIC4z9s1CRHNQBqrJfFGTUT86CECPaXM', 'appid' => 'wx6bc0c53a3a1c150d', 'appsecret' => '3888ccc01ec4e5d6e0e673308e92e627', 'debug' => true, 'logcallback' => '_log'];
    include dirname(__FILE__) . "/../qy-sdk/wechat.class.php";
    $weObj = new Wechat($options);
    return $weObj->sendTemplateMessage($notice_data);
}
开发者ID:adexbn,项目名称:gds_wechat,代码行数:11,代码来源:send_wechat_test.php

示例15: index

 public function index()
 {
     $wechat = new Wechat($this->config);
     $data = $wechat->request();
     list($content, $type) = $this->reply($data);
     if (!empty($content)) {
         $wechat->response($content, $type);
     } else {
         exit;
     }
 }
开发者ID:belerweb,项目名称:pigcms,代码行数:11,代码来源:WeixinAction.class.php


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