[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (fwd)
From: |
Sven Axelsson |
Subject: |
Re: (fwd) |
Date: |
Tue, 21 Mar 2017 13:21:39 +0100 |
Here's a simple solution in PHP to upload a Lilypond file to lilybin
and download the result after execution.
--->>> snip lilybin <<<---
#!/usr/bin/env php
<?php
function do_curl($url, $opts)
{
$curl = curl_init($url);
curl_setopt_array($curl, $opts);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
$optind = 0;
$opts = getopt('d', $argv, $optind);
$files = array_slice($argv, $optind);
if (count($files) !== 1) {
die("Usage: lilybin [-d] file\n");
}
if (isset($opts['d'])) {
$url = 'https://s3-us-west-2.amazonaws.com/lilybin-scores/' . $files[0];
$file = fopen($files[0], 'w');
do_curl($url, array(CURLOPT_FILE => $file));
fclose($file);
} else {
$url =
'https://7icpm9qr6a.execute-api.us-west-2.amazonaws.com/prod/prepare_preview/stable';
$result = json_decode(do_curl($url, array(
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => json_encode(array('code' =>
file_get_contents($files[0]))),
CURLOPT_RETURNTRANSFER => true,
)));
if (!$result->id) {
echo "ERROR:\n{$result->stderr}";
exit(1);
} else {
echo $argv[0], ' -d ', $result->id, ".pdf\n";
}
}
--->>> end snip lilybin <<<---
--
Sven Axelsson
++++++++++[>++++++++++>+++++++++++>++++++++++>++++++
>++++<<<<<-]>++++.+.++++.>+++++.>+.<<-.>>+.>++++.<<.
+++.>-.<<++.>>----.<++.>>>++++++.<<<<.>>++++.<----.
- Re: (fwd), Martin Tarenskeen, 2017/03/21
- Re: (fwd), Urs Liska, 2017/03/21
- Re: (fwd), Martin Tarenskeen, 2017/03/21
- Re: (fwd),
Sven Axelsson <=
- Re: (fwd), Martin Tarenskeen, 2017/03/21
- Re: (fwd), Sven Axelsson, 2017/03/22
- Message not available
- Re: (fwd), Sven Axelsson, 2017/03/22
- Re: (fwd), Martin Tarenskeen, 2017/03/22
- Re: (fwd), Sven Axelsson, 2017/03/22
- Message not available
- lilybin php script (was: Re: (fwd)), Martin Tarenskeen, 2017/03/23
- Re: lilybin php script (was: Re: (fwd)), Trevor, 2017/03/23
- Re: lilybin php script (was: Re: (fwd)), Martin Tarenskeen, 2017/03/23
- Re: lilybin php script (was: Re: (fwd)), Martin Tarenskeen, 2017/03/24
- Re: lilybin php script (was: Re: (fwd)), Martin Tarenskeen, 2017/03/27