首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >update_profile_banner Twitter COMPRESSION_ERROR图像

update_profile_banner Twitter COMPRESSION_ERROR图像
EN

Stack Overflow用户
提问于 2022-07-13 14:46:43
回答 1查看 105关注 0票数 1

我试图在Twitter中使用banner.json更新横幅图像。在查询参数中,可以使用2种格式类型发送图像。作为base64或原始数据。

当我用base64编码我的图像时,我认为它的大小超过了最大http长度。作为二进制文件发送似乎更不合逻辑,因为它比base64长。

代码语言:javascript
复制
Post "https://api.twitter.com/1.1/account/update_profile_banner.json?banner=%2F9j%2F2wCEAA...": http2: server sent GOAWAY and closed the connection; LastStreamID=7, ErrCode=COMPRESSION_ERROR, debug=""

我使用的库是达布尔/推特,但是我必须创建一个分叉,因为没有更新配置文件横幅的方法。我将以下函数和结构添加到accounts.go文件中。

代码语言:javascript
复制
type AccountUpdateProfileBannerPhotoParams struct {
    Banner string `url:"banner,omitempty"`
    Width   int    `url:"width,omitempty"`
    Height  int    `url:"height,omitempty"`
    OffsetX int    `url:"offset_left,omitempty"`
    OffsetY int    `url:"offset_top,omitempty"`
}

func (s *AccountService) UpdateProfileBannerPhoto(params *AccountUpdateProfileBannerPhotoParams) (*User, *http.Response, error) {
    user := new(User)
    apiError := new(APIError)
    resp, err := s.sling.New().Post("update_profile_banner.json").QueryStruct(params).Receive(user, apiError)
    return user, resp, relevantError(err, *apiError)
}

UpdateProfileBannerPhoto()函数返回上述错误消息。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-14 01:17:24

解决了这个问题。粗心大意!

我了解到Twitter使用了媒体/上载方法,然后通过跟踪网络流量将其发送到标语方法来更新media_id值。

但这是不需要的。我用QueryStruct更新了UpdateProfileBannerPhoto函数中的BodyForm,解决了问题.

固定:

代码语言:javascript
复制
func (s *AccountService) UpdateProfileBannerPhoto(params *AccountUpdateProfileBannerPhotoParams) (*User, *http.Response, error) {
    user := new(User)
    apiError := new(APIError)
    resp, err := s.sling.New().Post("update_profile_banner.json").BodyForm(params).Receive(user, apiError)
    return user, resp, relevantError(err, *apiError)
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72968242

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档