[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); } } }
声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事
R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)
1 か月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最高のグラフィック設定
1 か月前By尊渡假赌尊渡假赌尊渡假赌
アサシンのクリードシャドウズ:シーシェルリドルソリューション
3週間前ByDDD
Will R.E.P.O.クロスプレイがありますか?
1 か月前By尊渡假赌尊渡假赌尊渡假赌

ホットツール

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

ドリームウィーバー CS6
ビジュアル Web 開発ツール

WebStorm Mac版
便利なJavaScript開発ツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

メモ帳++7.3.1
使いやすく無料のコードエディター
