public function wx()
 {
     $we = new WeChat();
     $auth = $we->checkAuth();
     $js_ticket = $we->getJsTicket();
     if (!$js_ticket) {
         echo "获取js_ticket失败!<br>";
         echo '错误码:' . $we->errCode;
         echo ' 错误原因:' . ErrCode::getErrText($we->errCode);
         return;
     }
     $this->assign("get_url", $this->get_url());
     $url = $this->get_url();
     $js_sign = $we->getJsSign($url);
     //        $js_sign:
     //        array(5) {
     //            ["appId"] => string(18) "wxb5a48f9295510dd9"
     //            ["nonceStr"] => string(16) "g45Qq1xFr4hKPafy"
     //            ["timestamp"] => int(1452350509)
     //            ["url"] => string(44) "http://45.119.96.108/index.php/Home/Index/wx"
     //            ["signature"] => string(40) "3bd54ba365ee6616aceac7893baf1c88295533ab"
     //}
     $this->assign("js_ticket", $js_ticket);
     $this->assign("js_sign", $js_sign);
     $this->assign("appid", $we->getAppID());
     $this->display();
 }
Exemple #2
0
 public function test()
 {
     //        Log::write("ddddddddddddddddddddddddd");
     //        echo 111;
     //        return;
     //        dump(file_get_contents('@D:\PHP\www\login_Exit.html'));
     //        dump(error_get_last());
     $weObj = new WeChat();
     $weObj->checkAuth();
     $re = "";
     $data = array('button' => array(0 => array('name' => '扫扫码', 'sub_button' => array(0 => array('type' => 'scancode_waitmsg', 'name' => '扫码带提示', 'key' => 'rselfmenu_0_0'), 1 => array('type' => 'scancode_push', 'name' => '扫码推事件', 'key' => 'rselfmenu_0_1'), 2 => array('type' => 'view', 'name' => '百度', 'url' => 'http://www.baidu.com/'), 3 => array('type' => 'view', 'name' => '我的网页', 'url' => 'http://45.119.96.108/index.php?s=/Home/Index/wx'))), 1 => array('name' => '发图', 'sub_button' => array(0 => array('type' => 'pic_sysphoto', 'name' => '系统拍照发图', 'key' => 'rselfmenu_1_0'), 1 => array('type' => 'pic_photo_or_album', 'name' => '拍照或者相册发图', 'key' => 'rselfmenu_1_1'))), 2 => array('type' => 'location_select', 'name' => '发送位置', 'key' => 'rselfmenu_2_0')));
     //        $data = array(
     //            "button" => array(
     //                array(
     //                    'type' => 'click',
     //                    'name'=>'今日歌曲',
     //                    "key"=>"V1001_TODAY_MUSIC",
     //                ),
     //                array(
     //                  'name'=>  '菜单1',
     //                    'sub_button'=>array(
     //                        array(
     //                            'type'=>'view',
     //                            'name'=>'baidu',
     //                            'url'=>'http://www.baidu.com',
     //                        ),
     //                        array(
     //                            'type'=>'viwe',
     //                            'name'=>'163',
     //                            'url'=>'http://www.163.com',
     //                        ),
     //                    ),
     //                ),array(
     //                  'name'=>  '菜单2',
     //                    'sub_button'=>array(
     //                        array(
     //                            'type'=>'view',
     //                            'name'=>'baidu1',
     //                            'url'=>'http://www.baidu.com',
     //                        ),
     //                        array(
     //                            'type'=>'viwe',
     //                            'name'=>'1631',
     //                            'url'=>'http://www.163.com',
     //                        ),
     //                    ),
     //                ),
     //    ),
     //    );
     $weObj->createMenu($data);
     $re = json_encode($data);
     //        $weObj->createMenu($data);
     //        $data = array('media' =>'@D:\PHP\www\login_Exit.html');
     //        $re = $weObj->getShortUrl("http://mp.weixin.qq.com/wiki/6/856aaeb492026466277ea39233dc23ee.html");
     //        $re = $weObj->sendMassMessage(array(
     //            'touser' => array('oerqTv2OzH6PIAcDTEW_XYX_0CU8','oerqTv1SpVoA51JVNYqVPj_qsXKQ'),
     //            "msgtype" => "text",
     //            'text' => array("content" => "hellosasdfasd")
     //
     //        ));
     dump($weObj);
     dump($re);
     //        dump($weObj->getServerIp());
 }