-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuse-api.php
31 lines (30 loc) · 1.11 KB
/
use-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
<?php
if (isset($_POST)){
$code = $_POST['code'];
$lang = $_POST['lang'];
$token = $_POST['token'];
$ch = curl_init();
$fields = array(
"lang" => $lang,
"code" => $code,
"token" => $token
);
$postvars = '';
foreach($fields as $key=>$value) {
$postvars .= $key . "=" . $value . "&";
}
$url = "http://api.8bitbase.com/deploy/execute";
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST, 1); //0 for a get request
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT ,3);
curl_setopt($ch,CURLOPT_TIMEOUT, 20);
$response = curl_exec($ch);
curl_close ($ch);
print_r($response);
// Return
/*
{"error":"","message":"OK","result":"Hello, world!\r\n","stats":"Compilation time: 0,12 sec, absolute running time: 0,08 sec, cpu time: 0,08 sec, average memory usage: 13 Mb, average nr of threads: 2"}
*/
}