I want to submit some simple data from a php based database system to google apps engine.
The following code produces no error, but no result, too. I can't find out why google apps script does not react.
The google apps script is configured for use by anybody who knows the url (anonymous user is allowed). The script will be executed by my account, even if it is triggered bei anonymous user. The apps script has all the rights it needs to work.
The goal is that google apps script shows the posted data.
Any help will be very welcome. Maybe there is another method to transfer the data to google apps script. I could'nt find a solution after several hours of searching and trying.
On the PHP-System-side I've got the following code to SEND data:
// Get cURL resource
$curl = curl_init();
// Set some options
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://script.google.com/macros/s/AKfycbykWm97cwsxoP6NGhub8AqGuQammVwCwVgJrxjFLxY8TAFGRw/exec',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
'fname' => 'John',
'lname' => 'Miller'
)
));
// Send the request, save response to $resp
$resp = curl_exec($curl);
// Show response
echo $resp;
// Close request to clear up some resources
curl_close($curl);
echo 'curl closed';
On the Google apps script-side I've got the following code to RECEIVE data:
// Show name in google apps
function doPost(e) {
var parameter
var value
for (var i in e.parameters) {
parameter = i;
wert = e.parameters[i];
if (parameter == "lname") {var lname = value;}
if (parameter == "fname") {var fname = value;}
}
//Return
return HtmlService.createHtmlOutput("The name is: " + fname + " " + lname)
}