-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpubFeed.php
112 lines (89 loc) · 2.86 KB
/
pubFeed.php
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
// require "UCSFtest.php";
$investigators = array(
array( "fname" => "Deepak",
"lname" => "Srivastava",
"ucsfid" => "24044604",
"email" => "[email protected]",
),
array("fname" => "Katerina",
"lname" => "Akassoglou",
"ucsfid" => "24652877",
"email" => "[email protected]",
),
array( "fname" => "Lennart",
"lname" => "Mucke",
"ucsfid" => "27557024",
"email" => "[email protected]",
),
);
// echo "test<br>";
for ($x=0 ; $x< count($investigators) ; $x++ ){
echo $investigators[$x]["fname"]." ";
echo $investigators[$x]["lname"]."<br>";
echo $investigators[$x]["ucsfid"]."<br>";
echo $investigators[$x]["email"]."<br>";
$investigators[$x] = queryProfiles($investigators[$x]);
}
$guy["pubXML"] = array();
for ($x=0 ; $x< count($investigators) ; $x++ )
{
// echo &$guy."<br>";
// print_r($guy);
echo "<br>";
echo $investigators[$x]["fname"]." ";
echo $investigators[$x]["lname"]."<br>";
echo gettype($investigators[$x]["pubmedURLs"])."<br>";
$keys = ($investigators[$x]['pubmedURLs']);
foreach ( $keys as $pub){
$pubmedQuery = $pub."?=text&report=xml&format=text";
// echo $pubmedQuery."<br>";
if ( $handle = fopen($pubmedQuery, 'r')){
$xml = stream_get_contents($handle);
// echo $xml."<br>";
// echo "json type =\t".gettype($json)."<br>";
$pubXML = new SimpleXMLElement($xml);
array_push($guy["pubXML"], $pubXML);
}
}
}
function queryProfiles( $guy ){
$person_id = (int) ($guy["ucsfid"]/10) + 2569307;
echo $person_id."<br>";
$apiQuery = "http://profiles.ucsf.edu/CustomAPI/v1/JSONProfile.aspx?source=Gladstone&Person=".$person_id."&publications=full";
echo $apiQuery."<br>";
if ( $handle = fopen($apiQuery, 'r')){
$json = stream_get_contents($handle);
// echo $json."<br>";
// echo "json type =\t".gettype($json)."<br>";
}
$guy["PubJson"] = json_decode( $json , $assoc = true);
$guy["pubmedURLs"] = array();
$guy["pubWOpubmedID"] = array();
$keys1 = array_keys ( $guy["PubJson"]["Profiles"][0]['Publications']);
// [0]['PublicationSource'][0]['PublicationSourceURL'] );
foreach ( $keys1 as $key ){
// echo $key."<br>";
if (isset($guy["PubJson"]["Profiles"][0]['Publications'][$key]['PublicationSource'][0]['PublicationSourceURL'] )){
$URL = $guy["PubJson"]["Profiles"][0]['Publications'][$key]['PublicationSource'][0]['PublicationSourceURL'];
// echo $URL."<br>";
array_push($guy["pubmedURLs"], $URL);
}
else {
array_push($guy["pubWOpubmedID"] , $guy["PubJson"]["Profiles"][0]['Publications'][$key] );
}
}
echo gettype($guy["pubmedURLs"])."<br>";
$keys2 = array_keys ($guy['pubmedURLs']);
foreach ( $keys2 as $key ){
// echo $guy['pubmedURLs'][$key]."<br>";
}
$keys3 = array_keys ($guy["pubWOpubmedID"]);
foreach ( $keys3 as $key ){
// print_r($guy["pubWOpubmedID"][$key]);
// echo "<br>";
}
// echo "<br><br><br>";
// print_r($guy);
return $guy;
}