Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
87 lines (73 loc) · 2.4 KB
/
Copy pathindex.php
File metadata and controls
87 lines (73 loc) · 2.4 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
79
80
81
82
83
84
85
86
87
<?php
/*
* Copyright (c) PANGAEA - Data Publisher for Earth & Environmental Science
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once('src/config.php');
require_once('src/ORCID.php');
if (isset($_GET['signin'])) {
header('Location: https://orcid.org/oauth/authorize?' .
http_build_query(
array(
'response_type' => 'code',
'scope' => '/authenticate',
'show_login' => 'true',
'client_id' => $config['clientId'],
'redirect_uri' => $config['redirectUri']
)
)
);
}
?>
<html>
<body>
<div>
<?php
if (isset($_GET['code'])) {
$client = new ORCID($config['clientId'], $config['clientSecret']);
$response = $client->requestTokenForCode($_GET['code']);
$orcid = $response->{'orcid'};
echo 'Token: ' . $response->{'access_token'} . '<br/>';
echo 'Name: ' . $response->{'name'} . '<br/>';
echo 'ORCID: ' . $orcid . '<br/>';
$response = $client->requestOrcidBio($orcid);
$profile = $response->{'orcid-profile'};
$identifier = $profile->{'orcid-identifier'};
$bio = $profile->{'orcid-bio'};
$contact = $bio->{'contact-details'};
echo '<br/>';
echo '<b>ORCID BIO</b><br/>';
echo 'URI: ' . $identifier->uri . '<br/>';
if (isset($contact->{'email'})) {
echo 'Email: ' . $contact->{'email'}[0]->value . '<br/>';
}
$response = $client->requestOrcidWorks($orcid);
$profile = $response->{'orcid-profile'};
$activities = $profile->{'orcid-activities'};
$works = $activities->{'orcid-works'};
echo '<br/>';
echo '<b>ORCID WORKS</b><br/>';
foreach($works->{'orcid-work'} as $work) {
echo 'Title: ' . $work->{'work-title'}->{'title'}->{'value'} . '<br/>';
if (isset($work->{'journal-title'}->{'value'})) {
echo 'Journal: ' . $work->{'journal-title'}->{'value'} . '<br/>';
}
}
} else {
echo '<a href="?signin=true">ORCID Sing In</a>';
}
?>
</div>
</body>
</html>