-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetfiles.php
39 lines (27 loc) · 918 Bytes
/
getfiles.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
<?php
session_start();
$username=$_SESSION['login'];
$password=$_SESSION['password'];
$token=$_SESSION['token'];
$job_url = "https://foundation.iplantcollaborative.org/io-v1/io/list/$username";
//Create a php curl object
$ch = curl_init();
//Base url for foundation api for php curl
$ch_values = "$username:$password";
//Set php curl options.
curl_setopt($ch, CURLOPT_URL,$job_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $ch_values);
//Execute the php curl and grab the response
$response = curl_exec($ch);
$resultStatus = curl_getinfo($ch);
//Turn the response into json which php can manipulate
$handled_json = json_decode($response,true);
//If the php curl was successful, display the results, if not, print failed results
if($resultStatus['http_code'] == 200) {
print json_encode($handled_json['result']);
}
else{
print $resultStatus['http_code'];
}
?>