首页 > 作文

PHP实现支付宝登录

更新时间:2023-04-07 12:17:36 阅读: 评论:0

1.支付宝路由拼接    public function dev()    {        $http = 'https://openauth.alipaydev.com/oauth2/publicappauthorize.htm?';        $app_id = '';        $scope = 'auth_ur';        $redirect_uri = urlencode('谦受益满招损');        $state = '0';        $url = $http . 'app_id=' . $app_id . '&scope=' . $scope . '&redirect_uri=' . $redirect_uri . '&state=' . $state;        $this->redirect($url);    }

2.支付宝的回调页面

public function zhi()    {        $params = input();        require_once './plugins/auth/aopsdk.php';        $aop = new \aopclient ();        $aop->gatewayurl = 'https://openapi.alipaydev.com/gateway.do';        $aop->appid = '2016100200645172';        $aop->rsaprivatekey = '私钥';        $aop->alipayrsapublickey = '公钥';        $aop->apiversion = '1.0';        $aop->signtype = 'rsa2';        $aop->postchart = 'utf-8';        $aop->format = 'json';        $request = new \alipaysystemoauthtokenrequest ();        $request->tgranttype("authorization_code");        $request->tcode($params['auth_code']);        $result = $aop->execute($request);        $result = (new \think\collection($result))->toarray();        $access_token = $result['alipay_system_中国梦宣讲材料oauth_token_respon']->access_token ?? '';        if (!$access_token) {            echo json_encode(['msg' => 'code无效'], json_unescaped_unicode);        }        $request = new \alipayurinfosharerequest ();        $result = $aop-&g美康雅t;execute($request, $access_token);        \app\home\logic\auto::ali($result);        $list = \app\common\model\ur::where('open_type', 'alipay')->where('openid', $result->alipay_ur_info_sha未可厚非re_respon->ur_id)->find();        ssion('ur_info', $list->toarray());        $blank_url = ssion('blank_url') ?: 'home/index/index';        \app\home\logic\cartlo美白针有什么副作用gic::cookietodb();        $this->redirect($blank_url);    }

本文发布于:2023-04-07 12:17:33,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/a438f44f37d3a3aed3ccf7b4387b92c9.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:PHP实现支付宝登录.doc

本文 PDF 下载地址:PHP实现支付宝登录.pdf

下一篇:返回列表
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图