3 Star 13 Fork 5

三零网科 / ci-wechat-sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ci-wechat-sdk

CodeIgniter-wechat-sdk

环境支持

[1] php >= 5.6

[2] CodeIgniter 3.x

使用教程

Wechat文件夹放application/libraries目录下

使用例子

<?php 

class SanLing extends CI_Controller
{
	public function __construct() {
		parent::__construct();

		# 配置参数

		$config = array(
			'appid'        => '', //公众号appid
			'partnerkey'   => '', //商户支付密钥Key
			'appsecret'    => '', //公众号appsecret
			'mch_id'       => '', //商户身份ID
		);
		
		# 加载对应操作接口

		//文件夹名注意大写
		$this->load->library('Wechat/Wechat_oauth',$config);
		$this->load->library('Wechat/wechat_pay',$config);
	}

	public function index()
	{
		//获取用户信息
		$getOauth = $this->wechat_oauth->getOauthAccessToken();

		$openid       = $getOauth['openid'];
		$body         = '支付';
		$out_trade_no = date('YmdHis');
		$total_fee    = 1;
		$notify_url   = 'http://www.30pu.net/notify';

		$this->wechat_pay->getPrepayId($openid, $body, $out_trade_no, $total_fee, $notify_url, $trade_type = "JSAPI");

		$this->wechat_pay->createMchPay($info);

	}

	public function getOauthRedirect()
	{
		$redirect_uri =  $this->wechat_oauth->getOauthRedirect('http:'.base_url('test/index'),time());
		redirect($redirect_uri);
	}
}

##获取当前完整页面(推荐写在helper中)

if (!function_exists('getLocalUrl'))
{
	function getLocalUrl() {
        $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
        $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
        $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
        $relate_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : $path_info);
        return $sys_protocal.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '').$relate_url;
    }
}
The MIT License (MIT) Copyright (c) 2017 三零网科 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

CodeIgniter3.x微信类 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/sanling/ci-wechat-sdk.git
git@gitee.com:sanling/ci-wechat-sdk.git
sanling
ci-wechat-sdk
ci-wechat-sdk
master

搜索帮助