英文:
Encoding a URL string according to RFC 1738 using Go
问题
我正在尝试通过我的Go应用程序向Twitter发送请求,Twitter的API要求根据RFC 1738对消费者密钥和密钥进行编码。是否有一个内置的Go函数可以做到这一点?从我在net/url包中看到的内容来看,Go默认使用RFC 3986,我没有看到任何在http://golang.org/pkg/net/url/上允许我转换为RFC 1738的函数。
提前说明一下,我知道RFC 3986是较新的并且取代了1738,但Twitter API明确要求使用RFC 1738,所以我想我应该尝试这样做,以避免可能因为某个特殊情况而出现问题。为了澄清,我指的是此页面上“发出仅应用程序请求”部分的第1部分:https://dev.twitter.com/docs/auth/application-only-auth
英文:
I'm trying to send a request to Twitter through my Go application, and Twitter's API requires that you encode the consumer key and secret according to RFC 1738. Is there a Go function built to do this? From what I see in the net/url package, Go uses RFC 3986 by default, and I don't see any functions on http://golang.org/pkg/net/url/ that would allow me to convert to RFC 1738.
As a heads-up, I know that RFC 3986 is newer and obsoletes 1738, but the Twitter API asks specifically for RFC 1738 so I figured I should try to do that to avoid possibly getting screwed over by a corner case. For clarification, I'm talking about part 1 of the "Issuing application-only requests" section on this page: https://dev.twitter.com/docs/auth/application-only-auth
答案1
得分: 1
RFC 3986 更新了RFC 1738。通过遵守RFC 3986,您可以符合RFC 1738的要求,从而达到Twitter的期望。
因此,net/url包应该完全满足您的需求。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论