-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall_API.php
More file actions
115 lines (101 loc) · 3.18 KB
/
call_API.php
File metadata and controls
115 lines (101 loc) · 3.18 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
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
113
114
115
<?php
/**
* @package PaoloPlugin
Plugin Name: DRE Plugin
Description: Plugin to fetch stats from DOC Search
Version: 1.0.0
Author: Paolo Bondi
*/
function box() {
#Fetches JSON and returns it
function login(){
ob_start();
$curl = curl_init();
#Sends a GET to the API using OAuth tokens
curl_setopt_array($curl, array(
CURLOPT_URL => "https://search.doctorevidence.com/api/trends/stats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer LDW3Nhkdmc7ulnAbigJJQAAzlI4_EDDw",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
$obj = json_decode($response, true);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
return $obj;
}
}
#Assigns JSON to $done
$done = login();
#Bolded text/values
$label_count = number_format((round(floatval($done["label-count"]), -5, PHP_ROUND_HALF_UP))/1000000,1);
$term_count = number_format(round(floatval($done["term-count"]), -5, PHP_ROUND_HALF_UP)/1000000,1);
$article_count = number_format(round(floatval($done["article-count"]), -6, PHP_ROUND_HALF_UP)/1000000, 1);
#Lighter text/values
$clinical_trials =number_format($done["clinicaltrials-count"]);
$epar = number_format($done["epar-count"]);
$feed_entries_count = number_format($done["feed-entries-count"]);
$asco = number_format($done["asco-count"]);
$feed_count = floatval($done["feed-count"]);
$pub_med = number_format(round(floatval($done["medline-count"]))/1000000, 1);
$news = number_format(floatval($done["articles-by-category"]["news"]));
$official = number_format(floatval($done["articles-by-category"]["official"]));
$social = number_format(floatval($done["articles-by-category"]["social"]));
?>
<style>
object {
background-color: #EDEDED;
display: block;
width: 1350px;
height: auto;
padding: 15px;
border-radius: 7px;
margin-right: auto;
margin-left: auto;
text-align: center;
}
h2 {
font-weight: bolder;
font-size: 20;
}
h3{
font-weight: lighter;
}
</style>
<!DOCTYPE html>
<html>
<body>
<object>
<h2>
<font color="#545454";>
Our database currently contains ~<?php echo $article_count; ?> million documents and <?php echo $term_count; ?> million concepts (<?php echo $label_count; ?> million terms).
</font>
</h2>
<h3>
<font color ="#555555">
We currently index <a href="https://www.ncbi.nlm.nih.gov/pubmed/"> PubMed</a> (<?php echo $pub_med . " million"; ?>), <a href="http://www.clinicaltrials.gov"> ClinicalTrials.gov</a> (<?php echo $clinical_trials; ?>), EPAR (<?php echo $epar; ?>), ASCO (<?php echo $asco;?>), RSS feeds (<?php echo $feed_entries_count; echo " from " . $feed_count . " feeds"?>).
</font>
</h3>
<h3>
<font color="#555555">
Number of items per feed category: news: <?php echo $news; ?>, official: <?php echo $official; ?>, social: <?php echo $social ?>
</font>
</h3>
</object>
</body>
</html>
<?php
return ob_get_clean();
}
add_shortcode('box', 'box');
?>