PHP to Google WebApp returns "<H1>Moved Temporarily</H1>The document has moved"

google php
google app engine php 7
google cloud php mysql
google api php client
scripts api google
execute google api
google drive api php
python execute google app script

Does anyone know how to call a web app written in Google AppScript from PHP?

I've published my app to run as me and made it available to "everyone". The test url looks like this:

https://script.google.com/macros/s/xXxXxX/dev?Jobno=11&Pickupfrom=Aa&Deliverto=bb&Readyby=22&Deliverby=33

This link appends a new record into a google spreadsheet. The link only works if I submit it manually in a browser that is logged in to Google. If I log out of google it forwards me to a login page. This makes no sense to me. I don't understand why it's forcing authentication.

Any ideas?

The described behaviour is a feature:

https://developers.google.com/apps-script/guides/content#redirects

Redirects

For security reasons, content returned by the Content service isn't served from script.google.com, but instead redirected to a one-time URL at script.googleusercontent.com. This means that if you use the Content service to return data to another application, you must ensure that the HTTP client is configured to follow redirects. For example, in the cURL command line utility, add the flag -L. Check the documentation for your HTTP client for more information on how to enable this behavior.

PHP to Google WebApp returns "<H1>Moved Temporarily</H1>The , Google Cloud Platform makes development easy using PHP. @return Psr\Http\​Message\StreamInterface */ function App Engine. Deploy, manage, and scale  Step 1: Turn on the Google Apps Script API. Click this button to create a new Cloud Platform project and automatically enable the Google Apps Script API: Enable the Google Apps Script API. In resulting dialog click DOWNLOAD CLIENT CONFIGURATION and save the file credentials.json to your working directory.

Sounds like it has something to do with how it's published. Republish and change "Who has access to the app" to "Anyone, even anonymous" and you should resolve the problem.

Edit: also remember to save a new version before publishing

Quickstart for PHP in the App Engine Flexible , USER_EMAIL - Returns the email address of the user, if they have been authenticated using the Users API. Applications should use nickname for displayable  Quickstart for PHP in the App Engine Flexible Environment Region ID The REGION_ID is a code that Google assigns based on the region you select when you create your app. Including REGION_ID .r in App Engine URLs is optional for existing apps and will soon be required for all new apps.

You should use the "exec" version of your app, not the "dev" one.

And, as mentioned in the other answer, don't forget to save a version and update your deployment with this latest version.

The "dev" version is only used for test and is only accessible by the script editors when they are logged in.

Your url should look like this :

https://script.google.com/macros/s/xXxXxX/exec?Jobno=11&Pickupfrom=Aa&Deliverto=bb&Readyby=22&Deliverby=33

PHP, Google APIs Client Library for PHP. The Google API Client Library enables you to work with Google APIs such as Gmail, Drive or YouTube on your server. A web app client ID lets your app authorize users and access Google APIs. In the Google Cloud Platform Console, go to the Credentials page. Go to the Credentials page. Click OAuth consent screen. In the Application name field, enter PHP Bookshelf App.

PHP on Google App Engine | App Engine Documentation, Check the value for Google account – this should be your (correct) Google account. Click on Next. Now you select “Web application” (since PHP is mostly used  This will create a migrate-to-progressive-web-apps directory containing completed code for each step. For this codelab, load the work folder and make all changes there. Once the code is checked out, you should use the Simple HTTP Server application (or e.g., a local Python server or other HTTP server) to serve the work folder on port 8887 .

PHP 5 Runtime Environment, '/vendor/autoload.php'; define('APPLICATION_NAME', 'Google Apps Script Execution API @return Google_Client the authorized client object */ function getClient() For information on how to perform authorization in a web application, see  Your First Web App “Hello World” Let’s get a few easy examples out of the way. The next three code snippets serve essentially the same content in three different formats. To try them out: Copy and paste them into a new Google Apps Script. Click Publish on the main menu and then Deploy as web app… Click “Test web app for your latest code.”

googleapis/google-api-php-client: A PHP client library for , Learn how to add login functionality to your app with Google. Custom Databases · Active Directory/LDAP Connector · Extensions · Auth0 PHP SDK show you how to add functionality to your web app that allows your users to log in with Google. Google will include an Access Token in the user profile it returns to Auth0. HTML Service: Templated HTML You can mix Apps Script code and HTML to produce dynamic pages with minimal effort. If you've used a templating language that mixes code and HTML, such as PHP, ASP, or JSP, the syntax should feel familiar.

Comments
  • I did publish it so that anyone has access to it. I said "everyone" but that's what I meant.
  • I get the impression there is more to versioning than is obvious to me. I've made a lot of changes to the code since I saved the first version, however, since I haven't got it to work yet I just keep saving without updating the version. It doesn't make sense to me that I should update the version for every experimental tweak that hasn't even been tested yet. Since I keep reading such warnings about updating the version I'm starting to wonder if I should. Is that possibly what's preventing this from working?
  • Your comment here proves that I'm right ;-) the .dev url is actually there to test your code manually, only the script editor can run it, not an external PHP script. So save a new version when your manual tests are ok (which is the case apparently) and try again, it will work !
  • please read this doc carefully, it explains the versioning concept quite clearly.
  • I have never heard of such a thing. It didn't work but clearly there is more to be learned about this. I have spent hours trying to figure this out and I've never seen that anywhere. Where do I learn more about this exec vs. dev stuff?
  • the documentation explains the 3 necessary steps you must follow to deploy a webApp If my solution didn't work it is most probably because you didn't save a new version with your latest code and didn't choose this version from the deplyment menu.
  • I saved another version. I saved several new versions. I changed it from dev to exec. It still takes me to a login page when I try it in a browser that is not logged in to a google account.
  • "Saved a new version", that's fine but did you choose the latest one in the deployment window?
  • Yes, I did. I always select the latest version. Is there something I am supposed to do when I save or select the version that identifies this as the version that is supposed to work? :) I wish it were that easy.