我正在嘗試使用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)
}
- 1 回答
- 0 關注
- 142 瀏覽
添加回答
舉報
0/150
提交
取消