Repository navigation
Expand file tree
/
Copy pathAuthTest.php
More file actions
78 lines (55 loc) · 2.28 KB
/
Copy pathAuthTest.php
File metadata and controls
78 lines (55 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
require '../vendor/autoload.php';
use Client\DefaultAlipayClient;
use MOdel\CustomerBelongsTo;
use Model\GrantType;
use Request\auth\AlipayAuthApplyTokenRequest;
use Request\auth\AlipayAuthConsultRequest;
use Request\auth\AlipayAuthRevokeTokenRequest;
const clientId = "";
const merchantPrivateKey = "";
const alipayPublicKey = "";
const gatewayUrl = "";
function applyToken($authCode)
{
$request = new AlipayAuthApplyTokenRequest();
$request->setGrantType(GrantType::AUTHORIZATION_CODE);
$request->setCustomerBelongsTo(CustomerBelongsTo::ALIPAY_CN);
$request->setAuthCode($authCode);
$alipayClient = new DefaultAlipayClient(gatewayUrl, merchantPrivateKey, alipayPublicKey, clientId);
$alipayResponse = $alipayClient->execute($request);
print(json_encode($alipayResponse));
}
function authConsult()
{
$request = new AlipayAuthConsultRequest();
$request->setAuthRedirectUrl("https://www.taobao.com/?param1=567¶m2=123");
$request->setAuthState("dd1F6F6811f989DC7");
$request->setCustomerBelongsTo(\Model\CustomerBelongsTo::ALIPAY_CN);
$request->setOsType(\Model\OsType::ANDROID);
$request->setOsVersion("6.6.6.6");
$request->setScopes([\Model\ScopeType::AGREEMENT_PAY]);
$request->setTerminalType(\Model\TerminalType::APP);
$alipayClient = new \Client\DefaultAlipayClient(gatewayUrl, merchantPrivateKey, alipayPublicKey, clientId);
$alipayResponse = $alipayClient->execute($request);
print(json_encode($alipayResponse));
}
function queryToken($accessToken)
{
$request = new \Request\auth\AlipayAuthQueryTokenRequest();
$request->setAccessToken($accessToken);
$alipayClient = new DefaultAlipayClient(gatewayUrl, merchantPrivateKey, alipayPublicKey, clientId);
$alipayResponse = $alipayClient->execute($request);
print(json_encode($alipayResponse));
}
function revoke_token($accessToken)
{
$request = new AlipayAuthRevokeTokenRequest();
$request->setAccessToken($accessToken);
$alipayClient = new DefaultAlipayClient(gatewayUrl, merchantPrivateKey, alipayPublicKey, clientId);
$alipayResponse = $alipayClient->execute($request);
print(json_encode($alipayResponse));
}
authConsult();
//applyToken("281001133029700579331362");
//revoke_token("28288803001247281723530452000N6krsDm8J8171000589");