duandu1966 2014-05-20 20:48
浏览 193
已采纳

使用Go根据RFC 1738编码URL字符串

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条回答 默认 最新

  • dougao9864 2014-05-21 10:35
    关注

    RFC 3986 updates RFC 1738. You can comply with RFC 1738 by complying with RFC 3986, and therefore achieve what Twitter expects.

    So the net/url package should fully meet your needs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?