亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang Twitter API - update_profile_banner 圖片壓縮錯誤

Golang Twitter API - update_profile_banner 圖片壓縮錯誤

Go
慕勒3428872 2023-01-03 14:10:12
我正在嘗試使用Twitter API 中的account/update_profile_banner.json更新橫幅圖像。在查詢參數中,據說圖像可以以 2 種格式類型發送。作為 base64 或原始數據。當我用 base64 編碼我的圖像時,我認為它的大小超過了最大 http 長度。以二進制形式發送似乎更不合邏輯,因為它比 base64 更長。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=""我使用的庫是dghubble/go-twitter,但我不得不創建一個分支,因為沒有更新個人資料橫幅的方法。我將以下函數和結構添加到 accounts.go 文件中。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()函數返回上述錯誤消息。
查看完整描述

1 回答

?
慕尼黑的夜晚無繁華

TA貢獻1864條經驗 獲得超6個贊

解決了問題。疏忽!


我了解到Twitter使用media/upload方法,然后通過跟蹤網絡流量media_id將其發送到account/update_profile_banner方法來更新值。


但這不是必需的。我更新了QueryStruct函數UpdateProfileBannerPhoto中BodyForm的,問題解決了......


固定的:


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)

}


查看完整回答
反對 回復 2023-01-03
  • 1 回答
  • 0 關注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號