用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1621|回复: 1
收起左侧

[版本 2.x] 一个微信接口的问题,求高手指点!

[复制链接]
发表于 2016-7-19 23:45:02 | 显示全部楼层 |阅读模式

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

define("TOKEN", "******");
define("WEIXIN_APPID", "*******");
define("WEIXIN_SECRET", "*******");

class Home extends Home_Controller {

public $CI;
public function __construct() {
                parent::__construct();
               $this->CI = &get_instance();
      
            }
            
      
public function valid()
    {
        $echostr = $this->CI->input->get('echostr');
        if($this->checkSignature()){
            echo $echoStr;
            exit;
        }
    }

    private function checkSignature()
    {
        $signature  = $this->CI->input->get('signature');
        $timestamp  = $this->CI->input->get('timestamp');
        $nonce      = $this->CI->input->get('nonce');

        $token = TOKEN;
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );

        if( $tmpStr == $signature ){
            return true;
        }else{
            return false;
        }
    }

public function index()
    {   
        if (isset($this->CI->input->get['echostr'])) {
    $this->valid();
}else{
    //$wechatObj->responseMsg();
    //$wechatObj->responseMsg2();
    //$wechatObj->responseMsg3();

}




    }
}
1、 填入微信平台URLhttp://www.hzcookie.com/weixin/index.php/home/index/;个人觉得这个地址是不是有问题?

2、2.0直接使用 $_GET,应该是没有问题吧。但好像都获取不到参数?


发表于 2016-7-20 10:55:53 | 显示全部楼层
我写过一个简单例子,你可以参考下 http://codeigniter.org.cn/forums ... &extra=page%3D1

本版积分规则