Hello,
Google Apps Scripts allows me to create a webapp function that returns json. For security reasons the url to call the function returns a redirection. For example Curl https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec
Returns an html page with the redirection information, whereas curl -L https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec
Returns the json value (currently 13) I tried to use ZnClient to do the same thing, and I thought that ZnClient automatically followed redirections, but when I inspect the value it seems to actually return a larger html page, rather than the json. My Pharo code is:
(ZnClient new) get: 'https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec'.
Do I have to set any other options? Please Note: this is my first experiment with Google App Scripts, so it is very likely that the problem is with my script, rather than Pharo. However, the script does seem to be returning the correct value in the browser, so it might be some interaction between the two.
Cheers Andy ᐧ
|
Hi Andy,
Your URL actually does return '13' for me with Zinc following the redirect: So the question is why doesn't it work for you ? Which version of Pharo and/or Zinc are you using ? Are you behind a proxy ? Sven On 16 Aug 2014, at 16:55, Andy Burnett <[hidden email]> wrote:
Hello, |
In reply to this post by Andy Burnett
ᐧ
Hi Sven, That sounds encouraging. I am running Pharo 3.0, but I don't know how to get the release number of Zinc. Is it stored in the class comments, or can I use monticello to get the info?
I am not behind a proxy By the way, using the ZnClient returns about 53K of text. The first chunk of which is: ' <!DOCTYPE html>
<html lang="en"> <head> <meta charset="utf-8"> <meta content="width=300, initial-scale=1" name="viewport">
<meta name="description" content="Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free.">
|
On 16 Aug 2014, at 17:50, Andy Burnett <[hidden email]> wrote: > ᐧ > Hi Sven, > That sounds encouraging. > > I am running Pharo 3.0, but I don't know how to get the release number of Zinc. Is it stored in the class comments, or can I use monticello to get the info? Yes, in the Monticello Browser, you can read the version of the package 'Zinc-HTTP', the latest is 409. But I can't remember that anything related to redirects changed recently. You could try using the latest 4.0 image which got a Zn update a couple of days ago. Or you could update Zinc in your image Gofer it url: 'http://mc.stfx.eu/ZincHTTPComponents'; configurationOf: #ZincHTTPComponents; loadVersion: #bleedingEdge. You will probably have to proceed some warnings. If you do ZnClient new logToTranscript; get: 'https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec'. you should get something like 2014-08-16 18:11:01 011 Connection Established script.google.com:443 173.194.112.14 132ms 2014-08-16 18:11:01 012 Request Written a ZnRequest(GET /macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec) 2ms 2014-08-16 18:11:04 013 Response Read a ZnResponse(302 Moved Temporarily text/html;charset=UTF-8 514B) 2572ms 2014-08-16 18:11:04 014 GET /macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec 302 514B 2574ms 2014-08-16 18:11:04 015 Following Redirect https://script.googleusercontent.com/macros/echo?lib=Mw_SnjVBc4Rat2UsxNpQia7HBrRXsAwLh&user_content_key=wW90OT_koAjByHBHsu_efyuqsjemk2EhRsDQ8ar4t38C7fhvlpKmScbwFVkQlrENN-VnLAZzQNvX9KM7W5sFwmKVmKVPvjtcm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnKs0K41-LhqTVAkaTBaMruySWI1Ofcu1_BDpJ2OW96vspInsasdj0Rj2Z1GsF_xH8URUiluvVaUM 2014-08-16 18:11:04 016 Connection Closed 173.194.112.14:443 2014-08-16 18:11:04 017 Connection Established script.googleusercontent.com:443 173.194.113.106 90ms 2014-08-16 18:11:04 018 Request Written a ZnRequest(GET /macros/echo?lib=Mw_SnjVBc4Rat2UsxNpQia7HBrRXsAwLh&user_content_key=wW90OT_koAjByHBHsu_efyuqsjemk2EhRsDQ8ar4t38C7fhvlpKmScbwFVkQlrENN-VnLAZzQNvX9KM7W5sFwmKVmKVPvjtcm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnKs0K41-LhqTVAkaTBaMruySWI1Ofcu1_BDpJ2OW96vspInsasdj0Rj2Z1GsF_xH8URUiluvVaUM) 0ms 2014-08-16 18:11:04 019 Response Read a ZnResponse(200 OK application/json;charset=utf-8 2B) 452ms 2014-08-16 18:11:04 020 GET /macros/echo?lib=Mw_SnjVBc4Rat2UsxNpQia7HBrRXsAwLh&user_content_key=wW90OT_koAjByHBHsu_efyuqsjemk2EhRsDQ8ar4t38C7fhvlpKmScbwFVkQlrENN-VnLAZzQNvX9KM7W5sFwmKVmKVPvjtcm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx_ryfhECjZEnKs0K41-LhqTVAkaTBaMruySWI1Ofcu1_BDpJ2OW96vspInsasdj0Rj2Z1GsF_xH8URUiluvVaUM 200 2B 452ms In any case, I need to see your output > I am not behind a proxy > > By the way, using the ZnClient returns about 53K of text. The first chunk of which is: > > ' > <!DOCTYPE html> > <html lang="en"> > <head> > <meta charset="utf-8"> > <meta content="width=300, initial-scale=1" name="viewport"> > <meta name="description" content="Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free."> > > > > Hi Andy, > > Your URL actually does return '13' for me with Zinc following the redirect: > > > > So the question is why doesn't it work for you ? > > Which version of Pharo and/or Zinc are you using ? > Are you behind a proxy ? > > Sven > > On 16 Aug 2014, at 16:55, Andy Burnett <[hidden email]> wrote: > > > Hello, > > > > Google Apps Scripts allows me to create a webapp function that returns json. For security reasons the url to call the function returns a redirection. For example > > > > Curl https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec > > > > Returns an html page with the redirection information, whereas > > > > curl -L https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec > > > > Returns the json value (currently 13) > > > > I tried to use ZnClient to do the same thing, and I thought that ZnClient automatically followed redirections, but when I inspect the value it seems to actually return a larger html page, rather than the json. My Pharo code is: > > > > (ZnClient new) get: 'https://script.google.com/macros/s/AKfycbyjVyXa9cYqYZg6kfSdiT8l6S0Q3LEzn6FvonoI1G1MzXeegrOB/exec'. > > > > Do I have to set any other options? > > > > Please Note: this is my first experiment with Google App Scripts, so it is very likely that the problem is with my script, rather than Pharo. However, the script does seem to be returning the correct value in the browser, so it might be some interaction between the two. > > > > Cheers > > Andy > > ? > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20140816/7b068587/attachment.html> > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: Screen Shot 2014-08-16 at 17.18.11.png > Type: image/png > Size: 105419 bytes > Desc: not available > URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20140816/7b068587/attachment.png> > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Pharo-users mailing list > [hidden email] > http://lists.pharo.org/mailman/listinfo/pharo-users_lists.pharo.org > > > ------------------------------ > > End of Pharo-users Digest, Vol 16, Issue 61 > ******************************************* > |
In reply to this post by Andy Burnett
ᐧ
And then, as if by magic, the problem vanished! I think the problem must have been something I was doing wrong at the Google end. Everything now works.
Thanks Sven |
Free forum by Nabble | Edit this page |