Repository navigation
Expand file tree
/
Copy pathechosignfunctions.php
More file actions
77 lines (61 loc) · 1.68 KB
/
Copy pathechosignfunctions.php
File metadata and controls
77 lines (61 loc) · 1.68 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
<?php
require_once('credentials.php');
// Get OAuth token (refresh token valid for 60 days or until revoked)
function getAuthToken() {
$params = array(
'refresh_token' => REFRESH_TOKEN,
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
'grant_type' => 'refresh_token'
);
$query = http_build_query($params, '', '&');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST'
)
);
$url = API_URL . 'oauth/refresh?' . $query;
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$access_token = json_decode($result)->access_token;
return $access_token;
}
// Send agreement from library
function sendAgreement($signer_email) {
$agreement_id = 'WHiuUBCAABAA_Fake-DOcuMENt_ID-m9ms0CBJCH'; // libraryDocumentID
$requestbody = array(
"fileInfos" => array(
array(
"libraryDocumentId" => $agreement_id
)
),
"name" => "NPL Subscriber Agreement",
"participantSetsInfo" => array(
array(
"memberInfos" => array(
array(
"email" => $signer_email
)
),
"order" => 1,
"role" => "SIGNER"
)
),
"signatureType" => "ESIGN",
"state" => "IN_PROCESS"
);
$options = array(
'http' => array(
'header' => "Authorization: Bearer " . getAuthToken() . "\r\n" .
"Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($requestbody)
)
);
$url = API_URL . 'api/rest/v6/agreements';
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
?>