首页 > php教程 > PHP源码 > 正文

Ecshop微信第三方授权扫码登录接口文件源码

PHP中文网
发布: 2016-05-26 08:20:11
原创
2110人浏览过

[PHP]代码 

<?php 
/***************************/
/* Wechat 登录              /
/* by tiandi 2014.12.6      /
/***************************/  

if (defined('WEBSITE') || defined('GETINFO'))
{
	global $_LANG;
	$_LANG['help']['APP_KEY'] = '在微信开发者平台申请的AppID';
	$_LANG['help']['APP_SECRET'] = '在微信开发者平台申请的AppSecret';
	
	$_LANG['APP_KEY'] = 'AppID';
	$_LANG['APP_SECRET'] = 'AppSecret';
	
	$i = isset($web) ? count($web) : 0;
	// 类名
	$web[$i]['name'] = 'wechat';
	// 文件名,不包含后缀
	$web[$i]['type'] = 'wechat';
	
	$web[$i]['className'] = 'wechat';
	
	// 作者信息
	$web[$i]['author'] = 'tiandi';
	
	// 作者QQ
	$web[$i]['qq'] = '';
	
	// 作者邮箱
	$web[$i]['email'] = '';
	
	// 申请网址
	$web[$i]['website'] = 'http://open.weixin.qq.com';
	
	// 版本号
	$web[$i]['version'] = '1.0';
	
	// 更新日期
	$web[$i]['date']  = '2014-12-6';
	
	// 配置信息
	$web[$i]['config'] = array(
		array('type'=>'text' , 'name'=>'APP_KEY', 'value'=>''),
		array('type'=>'text' , 'name' => 'APP_SECRET' , 'value' => ''),
	);
}


if (!defined('WEBSITE'))
{
	include_once(dirname(__FILE__).'/oath2.class.php');
	class website extends oath2
	{
		function website()
		{
			$this->app_key = APP_KEY;
			$this->app_secret = APP_SECRET;
			
			$this->scope = 'snsapi_login';
			//by tiandi authorizeURL是用来PHP打开微信登录时用,JS调用则不用authorizeURL。
			$this->authorizeURL = 'https://open.weixin.qq.com/connect/qrconnect';

			$this->tokenURL = 'https://api.weixin.qq.com/sns/oauth2/access_token';
			$this->refreshtokenURL = 'https://api.weixin.qq.com/sns/oauth2/refresh_token';
			$this->userURL = 'https://api.weixin.qq.com/sns/userinfo';
			$this->meth = 'GET';
		}

		function Code2Token($code)
		{
			$params  = 'appid='.$this->app_key.'&secret='.$this->app_secret.'&code='.$code.
				'&grant_type=authorization_code';
			$tokenurl = $this->tokenURL."?". $params;
			$token = $this->http($tokenurl, 'GET');
			$token = json_decode($token , true);
			return $token;
		}

		function GetRefreshToken($token)
		{
			$params  = 'appid='.$this->app_key.'&grant_type=refresh_token&refresh_token='.$token;
			$tokenurl = $this->refreshtokenURL."?". $params;
			$token = $this->http($tokenurl, 'GET');
			$token = json_decode($token , true);
			return $token;
		}
		
		function Getinfo($token,$openid)
		{
			$params = 'access_token='.$token.'&openid='.$openid;
			$userurl = $this->userURL."?". $params;
			$userinfo = $this->http($userurl, 'GET');
			return json_decode($userinfo , true);
		}
	}
}
登录后复制

                   

ecshop多接口支付插件
ecshop多接口支付插件

此插件安装后,ECSHOP程序即可拥有:网银、信用卡、银联卡、支付宝、微信等多家支付接口,实现ECSHOP程序PC支付及WAP手机扫码支付等。此插件由“中云支付”提供。安装方法:第一步:备份ECSHOP源程序文件。第二步:上传压缩包中的includes\modules\payment目录下的cnzyzf.php、cod.php、syl.php文件和languages\zh_cn\payment目录

ecshop多接口支付插件 0
查看详情 ecshop多接口支付插件

                   

相关标签:
php
微信app下载
微信app下载

微信是一款手机通信软件,支持通过手机网络发送语音短信、视频、图片和文字。微信可以单聊及群聊,还能根据地理位置找到附近的人,带给大家全新的移动沟通体验,有需要的小伙伴快来保存下载体验吧!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号