例外:超过限制:urlfetch URL长度
我正在从API中提取数据,不幸的是,该数据的URL/端点很大。 是否有任何方法可以缩短URL以绕过例外:超过限制:urlfetch URL长度误差?
我发现了这一点: https://github.com/github.com/amitwilson/amitwilson/googleappsscript/blob/master/ LinkShortner ,但我不知道如何正确使用它,因为我进行的大多数API调用都是动态生成的。
这是一个示例链接(“ Cursor =”之后的字母是一个光标键,每次都不同):
https://api.x.immutable.com/v1/orders?include_fees = false=false&status; status; status = fill& buy_token_address = 0xacb3c6a43d15b907e8433077b6d38AeAe40936fe2c& orde_by = updated_timestamp&amp&amp&amp&amp = desc& use = desc& use = 0x72a2ffa8be361d4aa am am ; page_size = 200& cursor = _
I am pulling data from an API which unfortunately has very big urls/end points.
Is there any way to shorten urls in order to bypass the Exception: Limit Exceeded: URLFetch URL Length error?
I found this: https://github.com/amitwilson/GoogleAppsScript/blob/master/LinkShortner but I don't know how to use it properly since most of the api calls i make are generated dynamically.
This is an example link (letters after "cursor=" is a cursor key which is different every time):
https://api.x.immutable.com/v1/orders?include_fees=false&status=filled&buy_token_address=0xacb3c6a43d15b907e8433077b6d38ae40936fe2c&order_by=updated_timestamp&direction=desc&user=0x72a2ffa8be361d4a5d575c55b7382d8c6317f77d&page_size=200&cursor=eyJvcmRlcl9pZCI6MTk0NTk2NzUyLCJzZXFfbnVtIjowLCJzdGF0dXMiOiJmaWxsZWQiLCJzdGFya19rZXkiOiIweDA3MWU2NjU0NTMzMGJiOGY5NDQ4ZWU1YTM3YTI5ODViZGYzYjQ1NzYwNDA5ODE4YmEwYTY0NmUxNjU4NTdhMWIiLCJ2YXVsdF9pZCI6MCwiZXRoZXJfa2V5IjoiMHg3MmEyZmZhOGJlMzYxZDRhNWQ1NzVjNTViNzM4MmQ4YzYzMTdmNzdkIiwic2VsbF90b2tlbl90eXBlIjoiRVRIIiwic2VsbF90b2tlbl9pZCI6IiIsInNlbGxfY2xpZW50X3Rva2VuX2lkIjoiIiwic2VsbF90b2tlbl9hZGRyZXNzIjo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AzVDEwOjIwOjM0Ljc4ODkxN1oiLCJ1cGRhdGVkX2F0IjoiMjAyMi0wNS0wM1QxMDoyMDozNC43ODg5MTdaIiwiRmVlcyI6Ilczc2lZVzF2ZFc1MElqb2dJakk0TkRNd01EQXdNREF3TURBd0lpd2dJbVpsWlY5MGVYQmxJam9nSW0xaGEyVnlJaXdnSW05eVpHVnlYMmxrSWpvZ01UazBOVGsyTnpVeUxDQWljbVZqYVhCcFpXNTBYMlYwYUdWeVgydGxlU0k2SUNJd2VEVmpNell6WVRKaFlUZzJPV1F3WXpVeU1XTm1ZVE5sWWpCbE16YzBPVEpqTUdWaU5UbGxOVGdpTENBaWNtVmphWEJwWlc1MFgzTjBZWEpyWDJ0bGVTSTZJQ0l3ZURBMk1UY3haVEpoWlRRMU5qTXlNVE15TWpaak5XWm1aV1JpT1RSaE9UVXlOV0ppWm1Zell6bGtZMkpoWm1KaFpURTVabUk0TjJOa1ltSXpOMk5sTVdVaWZWMD0ifQ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,在您的情况下,以下示例脚本怎么样?
示例脚本:
在使用此脚本之前,请设置
apikey
和yourdynamiclinkdomain
。您的yourdynamicLinkDomain
可能就像https://##.page.link
。longurl
。并且,此示例脚本从长URL转换为短URL,并使用功能getShorturl _
将其转换为短URL。而且,您可以使用urlfetchapp使用此简短的URL。注意:
此示例脚本假设您已经能够使用Firebase Dynamic Links API。请小心。
如果您从未能够使用Firebase Dynamic Links API,请检查官方文件。而且,以下流程可能很有用。
请检查以下流程。
dynamiclinkdomain
。当我测试此脚本时,我可以确认将长URL转换为短URL,并且可以与urlfetchapp一起使用短URL。
如果我误解了
,但是我不知道如何正确使用它,因为我进行的大多数API调用都是动态生成的。
,请告诉我。参考:
添加:
从您的以下答复中,
当我看到您的样本电子表格时,似乎您正在使用长URL作为
= importjson(ConcateNate(“ https://api.x.immutable.com/v1/orders?include_fees = fees = fees = false&Amp; Status = status = falledus = fillid& amp; buy_token_address = 0xacb3c6a43d15b907e8433077b6d38AeAe40936fe2c& amp; amp; orde_by = updated_timestamp&amp&amp&amp&amp = desc& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp》 = 200& cursor =“,w202),”,“ notruncate,Nohewers”)
。但是不幸的是,从您的问题和您的答复来看,我没注意到您正在这样使用。在这种情况下,需要通过如下修改我的示例脚本。
示例脚本:
请将以下脚本复制到电子表格的脚本编辑器并保存脚本。
当此脚本用于样品电子表格时,请将以下公式放在单元格“ A203”中。
condenate检索(“ https://api.x.immutable.com/v1/orders?include_fees = fees = false = false&status = status=fill by = updated_timestamp&方向= desc&用户= 0x8604808b82444444444df3f94850acd584cd584c5ad7d& page_size = 200& cursor =',w202)并且,使用
importjson
。使用缩短URL
注意:
此示例脚本假设您已经能够使用Firebase Dynamic Links API。请小心。
当我对您的样本电子表格测试上述脚本和公式时,我确认了这些值已检索。
In your situation, for example, how about the following sample script?
Sample script:
Before you use this script, please set
apiKey
andyourDynamicLinkDomain
. YouryourDynamicLinkDomain
might be likehttps://###.page.link
.longUrl
is obtained. And, this sample script converts from the long URL to the short URL with the functiongetShortUrl_
. And, you can use this short URL using UrlFetchApp.Note:
This sample script supposes that you have already been able to use Firebase Dynamic Links API. Please be careful about this.
If you have never been able to be used Firebase Dynamic Links API, please check the official document. And, the following flow might be useful.
please check the following flow.
dynamicLinkDomain
at "Dynamic Links".When I tested this script, I could confirm that the long URL is converted to the short URL and the short URL can be used with UrlFetchApp.
If I misunderstood about
but I don't know how to use it properly since most of the api calls i make are generated dynamically.
, please tell me.References:
Added:
From your following reply,
When I saw your sample Spreadsheet, it seems that you are using the long URL as
=importjson(CONCATENATE("https://api.x.immutable.com/v1/orders?include_fees=false&status=filled&buy_token_address=0xacb3c6a43d15b907e8433077b6d38ae40936fe2c&order_by=updated_timestamp&direction=desc&user=0x8604808B824C4444Fe4dF3f94850ACd584C5aD7d&page_size=200&cursor=",W202),"","noTruncate,noHeaders")
. But unfortunately, from your question and your reply, I couldn't notice that you are using it like that.In this case, it is required to use my sample script by modifying as follows.
Sample script:
Please copy and paste the following script to the script editor of your Spreadsheet and save the script.
When this script is used for your sample Spreadsheet, please put the following formula to the cell "A203".
CONCATENATE("https://api.x.immutable.com/v1/orders?include_fees=false&status=filled&buy_token_address=0xacb3c6a43d15b907e8433077b6d38ae40936fe2c&order_by=updated_timestamp&direction=desc&user=0x8604808B824C4444Fe4dF3f94850ACd584C5aD7d&page_size=200&cursor=",W202)
is shorten byshortenUrl()
. And, use the shorten URL withimportjson
.Note:
This sample script supposes that you have already been able to use Firebase Dynamic Links API. Please be careful about this.
When I tested the above script and formula to your sample Spreadsheet, I confirmed that the values are retrieved.