UrlFetchApp request fails in Menu Functions but not in Custom Functions (connecting to external REST API)

When UrlFetchApp is used by the custom function and the script editor, I think that the difference is whether IPv6 is used, while the address of IPv4 is changed every run. In this case, the results of the script editor and custom menu are the same. I thought that this might be the reason of … Read more

Cookie handling in Google Apps Script – How to send cookies in header?

Here you can find cookies specification: http://www.w3.org/Protocols/rfc2109/rfc2109 You have a potential issue in your code: response.getAllHeaders()[‘Set-Cookie’] can return either a string or a table of string if multiple ‘set-cookie’ attributes are sent back from the server. Eric is right, you cannot return the cookie without digesting it. Second error in your code: var opt2 = … Read more

How to use UrlFetchApp with credentials? Google Scripts

This question has been answered on another else where. Here is the summary: Bruce Mcpherson basic authentication looks like this… var options = {}; options.headers = {“Authorization”: “Basic ” + Utilities.base64Encode(username + “:” + password)}; Lenny Cunningham //Added Basic Authorization////////////////////////////////////////////////////////////////////////////////////////// var USERNAME = PropertiesService.getScriptProperties().getProperty(‘username’); var PASSWORD = PropertiesService.getScriptProperties().getProperty(‘password’); var url = PropertiesService.getScriptProperties().getProperty(‘url’);//////////////////////////Forwarded Ports to WebRelay … Read more

A very simple multithreading parallel URL fetching (without queue)

Simplifying your original version as far as possible: import threading import urllib2 import time start = time.time() urls = [“http://www.google.com”, “http://www.apple.com”, “http://www.microsoft.com”, “http://www.amazon.com”, “http://www.facebook.com”] def fetch_url(url): urlHandler = urllib2.urlopen(url) html = urlHandler.read() print “‘%s\’ fetched in %ss” % (url, (time.time() – start)) threads = [threading.Thread(target=fetch_url, args=(url,)) for url in urls] for thread in threads: thread.start() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)