Ecshop WeChat サードパーティ認定スキャン コード ログイン インターフェイス ファイル ソース コード

WBOY
リリース: 2016-07-25 08:46:34
オリジナル
1925 人が閲覧しました
記事「WeChat サードパーティ認証スキャン コード ログインの実装」の中で、Tiandi は Ecshop システムに WeChat サードパーティ認証ログインを実装する方法を簡単に説明し、主にユーザーのログイン判定を変更するコア コード、つまりファイルを公開しました。ユーザー.php
  1. /***************************/
  2. /* Wechatログイン/
  3. /* by tiandi 2014.12.6 /
  4. /***************************/
  5. if (定義('WEBSITE' ) || 定義('GETINFO'))
  6. {
  7. グローバル $_LANG;
  8. $_LANG['help']['APP_KEY'] = 'WeChat 開発者プラットフォームに適用された AppID';
  9. $_LANG['help'] [' APP_SECRET'] = 'WeChat 開発者プラットフォームに適用された AppSecret';
  10. $_LANG['APP_KEY'] = 'AppID';
  11. $_LANG['APP_SECRET'] = 'AppSecret';
  12. $i = isset ($web) ? count($web) : 0;
  13. // クラス名
  14. $web[$i]['name'] = 'wechat';
  15. // サフィックスを除くファイル名
  16. $web[$i ]['type' ] = 'wechat';
  17. $web[$i]['className'] = 'wechat';
  18. // 著者情報
  19. $web[$i]['author'] = 'tiandi ';
  20. / / 著者 QQ
  21. $web[$i]['qq'] = '';
  22. // 著者のメールアドレス
  23. $web[$i]['email'] = '';
  24. // アプリケーション URL
  25. $web [$i]['website'] = 'http://open.weixin.qq.com';
  26. // バージョン番号
  27. $web[$i]['version'] = '1.0 ';
  28. / / 更新日
  29. $web[$i]['date'] = '2014-12-6';
  30. // 設定情報
  31. $web[$i]['config'] = array(
  32. array('type '=>'テキスト' , '名前'=>'APP_KEY', '値'=>''),
  33. array('タイプ'=>'テキスト' , '名前' = > 'APP_SECRET' , 'value' => ''),
  34. );
  35. }
  36. if (!define('WEBSITE'))
  37. {
  38. include_once(dirname(__FILE__).'/oath2.class.php');
  39. class website extends oath2
  40. {
  41. function website()
  42. {
  43. $this->app_key = APP_KEY;
  44. $this->app_secret = APP_SECRET;
  45. $this->scope = 'snsapi_login' ;
  46. //by tiandi authorizeURL は、PHP で WeChat ログインを開くときに使用され、JS を呼び出すときは authorizeURL は使用されません。
  47. $this->authorizeURL = 'https://open.weixin.qq.com/connect/qrconnect';
  48. $this->tokenURL = 'https://api.weixin.qq.com/sns/ oauth2/access_token';
  49. $this->refreshtokenURL = 'https://api.weixin.qq.com/sns/oauth2/refresh_token';
  50. $this->userURL = 'https://api.weixin. qq.com/sns/userinfo';
  51. $this->meth = 'GET';
  52. }
  53. function Code2Token($code)
  54. {
  55. $params = 'appid='.$this->app_key.' &secret='.$this->app_secret.'&code='.$code.
  56. '&grant_type=authorization_code';
  57. $tokenurl = $this->tokenURL."?" $token = $this ->http($tokenurl, 'GET');
  58. $token = json_decode($token , true);
  59. return $token;
  60. }
  61. function GetRefreshToken($token)
  62. {
  63. $params = 'appid=' .$this->app_key.'&grant_type=refresh_token&refresh_token='.$token;
  64. $tokenurl = $this->refreshtokenURL."?" $params;
  65. $token = $this->http($tokenurl, 'GET');
  66. $token = json_decode($token , true);
  67. return $token;
  68. }
  69. function Getinfo($token,$openid)
  70. {
  71. $params = 'access_token='.$token.' &openid='.$openid;
  72. $userurl = $this->userURL."?". $params;
  73. $userinfo = $this->http($userurl, 'GET');
  74. return json_decode($userinfo) 、 true);
  75. }
  76. }
  77. }
コードをコピー
エクショップ

ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!