-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
47 lines (43 loc) · 1.21 KB
/
api.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
<?php
$data = file_get_contents($_GET['url']);
$data = base64_encode($data);
$playload = '{
"Parameters": [
{
"Name": "File",
"FileValue": {
"Name": "'.basename($_GET['url']).'",
"Data": "'.$data.'"
}
},
{
"Name": "StoreFile",
"Value": true
}
]
}';
// Prepare new cURL resource
$ch = curl_init('https://v2.convertapi.com/convert/'.$_GET['from'].'/to'.'/'.$_GET['to'].'?Secret=3mI7vWnlb36ozE7A&StoreFile=true');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $playload);
// Set HTTP Header for POST request
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($playload))
);
// Submit the POST request
$result = curl_exec($ch);
$output = json_decode($result,true);
$count = count($output['Files']);
$i =0;
while($i<$count){
?>
<iframe src="<?php echo $output['Files'][$i]['Url']; ?>" style="display:none;"></iframe>
<?php
$i++;
}
// Close cURL session handle
if(curl_close($ch)){header("location:".$_GET['redirecturi']);}
?>