1. 云栖社区>
  2. PHP教程>
  3. 正文

支付宝获取页面静态授权

作者:用户 来源:互联网 时间:2017-11-30 19:46:54

支付页面静态授权获取

支付宝获取页面静态授权 - 摘要: 本文讲的是支付宝获取页面静态授权, <?phpif(empty($_GET['auth_code'])){ echo '<script>window.location.href = "https://openauth.alipay.com/oauth

<?phpif(empty($_GET['auth_code'])){    echo '<script>window.location.href = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2016112703399275&scope=auth_base&redirect_uri=https://group.greenmangodata.com/gpd.php";</script>';}else{$pri_key=<<<END-----BEGIN RSA PRIVATE KEY-----MIIEogIBAAKCAQEAvKixX4XSpfdv0uYg0h5TezeFY00L7Njn0aXlKaofCwYYn3tFS/rNgKypyL5bdE/zun3QJMx6+lcefPPWBRHJ2LzgaJGnH4XolKxUByW2XUL+AOWIfX02NeQMVt87miinNNdiP4zeS5iF8o0ul+BWZgXcoXJcVngDuE2BtsSnPwMvWT67hjaFtW5N2+32opZzqOrBpXBxyLbuiI7F+IfbZPejCilAEwxFkgYbIcI3wsTjy0v5jXMZcjFWBAGEuXUrUe97aMDdkK+LyGQcL7xblr83PxvpukZOXKfoUD7BGs22cC9Hpd9Q9/sKAz84L7a6rfFl8XCHoZ0Ll6Yuj+Kn8QIDAQABAoIBAEdPbFwy9UCOmtIY8mb514xHnD/Aq7VG97ki/9AT4dAE6eG+cp8Zmfv9R9/9NAxu/C2NyNNgB0wBCiEo+cjIxIcMPbbI92bO8u7fhJN/CcOOwvwLxt/IKGmOXauojZrjqvAqSZTD5nKkoFziSK5XudCufor38zcr/hv4EAPJqX4DS9iPnt3Eym1KT+nVla1uuIKZEvPWyDz37r1T0zC8sQU1m2FROk7ojJvWcUYktknk+VIpSRVccLsG2cY6FnJgXD/O9M50iFKWjGp3TwGFTawaW40GOqngVIbscX5Ly+GKmYPPjtW6ceD+YNtSEf3/i6c6MeNuV2/Q3Z0OnPEoIZECgYEA5ruhJPOqLGgzIPw8/7Ic54GXvM1EwboF4iAUgCKQCF5UAkQaj+8Ma2035/Zf3eTPoks4D7WZyZG/Iedt+/e0Lm+0nogoHtIU/S878zspQo5bkYwkQ4LzO7S2W4G1KZ//Cw6+EhqUjBF/D+013AjgjsTKAZ+TiIiTbytW14nX3ScCgYEA0VGPn0e7WNNSGtlvFBeTUlnSXLepbx6axVY4tPw0vKSaHUqzlc67pqza9iZnOW6P/QOLOEX/B/S0n7NgBXc8T26TxbbKhwgHp9g9bu4qBwlhiutKkxN0UwaDN5/QNtHriE1MziWhlLUK5q51B34qcMp2dUBK7FmPvBvTD24osScCgYBizbYTvMQCgBxk4567X+pAuJ3hm4T18FLUoiglNqe27a3Lyp4VRKhs2Dg4fKhQvMqtFMjM8VcJmf/e5NuUKl5eBDe0K1oC2LNkN/XUEmF4vr03dmuQ/WJrDteIF+McEAeHFKkP15IE6PkgONP3hVWjzWEzkMH8lX+M+2IUqlJlwQKBgD/A4Ma5uWU3kAVffoaXG6b0dq8IvZF7t9YtCb6OJp3iYJJVY1dYjS0Z7uMUFVKXy0Fb5/Zu01uf+7e8kZ14kKT84ANTRmJUXsiPgz6bSa+0+sGuIpujTEXRcPvrMCbSTzPHn4IWUh2R+s0CC+EJW3HZKLVTrL5KFQ5NRz6m5bv3AoGAMgduS1HH/Zmobgj7HTw3PLqxNmGDtq6vikc2cxbF4Y5elQzEyGzGcwLg8BEU9MMaVHq8M4wp55DHXPwFtcH6LXGASqizNbGuPWluppQloIUk7HvJzEQKO8pGaadhKdr/9n+cGSpf8VSAtwlH+xLVwnTyf87ngoTDoDzcEjOsbHo=-----END RSA PRIVATE KEY-----END;// 定义AliPriKey为支付宝青芒服务商私钥define("AliPriKey",$pri_key);function alipay_native_request(array $Params, string $Method){   $Params["charset"] = "utf-8";    $Params["format"] = "JSON";    $Params["method"] = $Method;        $Params["sign_type"] = "RSA2";    $Params["timestamp"] = gmdate("Y-m-d H:i:s");    $Params["version"] = "1.0";    ksort($Params); $Params = array_filter($Params);    $SignStr = urldecode(http_build_query($Params));    if(openssl_sign($SignStr, $Sign, AliPriKey, OPENSSL_ALGO_SHA256) != true) return false;    $Params["sign"] = base64_encode($Sign);    $hCurl = curl_init("https://openapi.alipay.com/gateway.do?".http_build_query($Params));    curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, true);    $JsonArr = json_decode(curl_exec($hCurl), true);    curl_close($hCurl);     return  $JsonArr;}$data=array();$data["app_id"] = "2016112703399275";$data['code']=$_GET['auth_code'];$data["grant_type"] = "authorization_code";header("Content-type:text/html;charset=gb2312");$rst=array();$rst=alipay_native_request($data, "alipay.system.oauth.token");if(empty($rst['alipay_system_oauth_token_response'])){    $data=array();    $data['status']=0;    $data['msg']="fail";    echo json_encode($data);    exit;}else{    $data=array();    $data['status']=1;    $data['user_id']=$rst['alipay_system_oauth_token_response']['user_id'];    echo json_encode($data);    exit;}}?>

th7cn

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索支付 , 页面 , 静态 , 授权 获取 ,以便于您获取更多的相关知识。