'com.alipay.account.auth', 'method' => 'alipay.open.auth.sdk.code.get', 'app_id' => AlipayConfig::APPID, 'app_name' => 'mc', 'biz_type' => 'openservice', 'pid' => AlipayConfig::PID, 'product_id' => 'APP_FAST_LOGIN', 'scope' => 'kuaijie', 'target_id' => md5(uniqid()), 'auth_type' => 'AUTHACCOUNT', 'sign_type' => 'RSA2', ]; $aopClient = new \AopClient; $paramStr = $aopClient->getSignContent($param); $param['sign'] = $aopClient->alonersaSign($paramStr, AlipayConfig::APPPRIVATEKEY, 'RSA2'); return $aopClient->getSignContentUrlencode($param); } public function getUseridFromAlipay($code) { $aop = new \AopClient; $aop->gatewayUrl = AlipayConfig::GATEWAY; $aop->appId = AlipayConfig::APPID; $aop->rsaPrivateKey = AlipayConfig::APPPRIVATEKEY; $aop->alipayrsaPublicKey = AlipayConfig::ALIPAYPUBLICKEY; $aop->apiVersion = '1.0'; $aop->signType = 'RSA2'; $aop->postCharset = 'UTF-8'; $aop->format = 'json'; $request = new \AlipaySystemOauthTokenRequest; $request->setGrantType('authorization_code'); $request->setCode($code); $result = $aop->execute($request); $responseNode = str_replace('.', '_', $request->getApiMethodName()) . '_response'; $userid = property_exists($result, $responseNode) ? $result->$responseNode->user_id : 0; return $userid; } }