Copy the following into a .php file:
<?php // ------------------------------------------- // Configuration // ------------------------------------------- $formID = 'INSERT-FORM-ID-HERE'; $post_data = [ # Barcode: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['data'], # Scanner ID: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['id'], # Timestamp from scanner: 'INSERT-FORM-INPUT-NAME-HERE' => date('Y-m-d H:i:s', @$_GET['time']), //to store the UTC timestamp (rather than in the server's time zone) replace 'date' with 'gmdate' in this line # Latitude: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['lat'], # Longitude: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['long'], # Scan point: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['scanpoint'], # Quantity: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['qty'], # App version: 'INSERT-FORM-INPUT-NAME-HERE' => @$_GET['ver'], # IP address: 'INSERT-FORM-INPUT-NAME-HERE' => $_SERVER['REMOTE_ADDR'], ]; // ------------------------------------------- // Normally no change is needed below here // ------------------------------------------- // Post the data to the form $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://docs.google.com/forms/d/'. $formID .'/formResponse'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $responseHtml = curl_exec($ch); unset($ch); // Determine response to send to the app $appResponse = []; if (strpos($responseHtml, 'class="errorMessage"') !== false) { if (preg_match('|class="errorMessage".*>(.*)<|iU', $responseHtml, $match)) { $errMsg = $match[1]; } else { $errMsg = 'Could not read form result. Barcode probably not registered.'; } $appResponse = ['status' => 'error', 'err_msg' => $errMsg]; } elseif (strpos($responseHtml, 'forms/d/'. $formID .'/viewform') === false) { $appResponse = ['status' => 'error', 'err_msg' => 'Could not find form ID in the result but did not find an error message either. Barcode might have been successfully registered though...']; } else { $appResponse = ['status' => 'ok', 'result_msg' => 'Barcode registered']; } echo json_encode($appResponse);