[twitter-dev] Re: API profile image update
Hi. I finally managed to get my image update code working, too. In case someone still has problems here are my findings / observations: * There only must be one blank line between HTTP request header and body (java jersey created two). * Newlines in request header and multipart headers must be CR/LF (both characters). * It is NOT important that the following headers exist - you CAN skip them: User-Agent, Content-Length. Expect * The blank before "boundary" in "Content-Type: multipart/form-data; boundary=..." is NOT important. * But it IS important that you mention the boundary in the content type header (jersey skipped it). * Each part of the multipart content begins with "--" + boundary * The end of the last part is marked with "--" + boundary + "--" * It is important that the header of the file part also contains a filename. Taken together the working request looks like this ("working" of course only after you have to inserted real authentication and binary data). POST https://twitter.com/account/update_profile_background_image.xml Authorization: Basic your_auth_string Content-Type: multipart/form-data; boundary=some_unique_string --some_unique_string Content-Disposition: form-data; name="image"; filename="image.gif" Content-Type: image/gif your binary data goes here --some_unique_string Content-Disposition: form-data; name="tile" Content-Type: text/plain true --some_unique_string-- Thanks to josh (he sent me his findings via private mail). Thanks to David, too (he wrote about the problem with two blank lines between header and body in http://groups.google.com/group/twitter-development-talk/browse_thread/thread/4fe78c5c7fb5cbdf/59f9ef7c8f745f93 Mitchel
[twitter-dev] Re: API profile image update
Hi Josh, can you please give me / us an hint about what exactly you have done wrong trying to update twitter images in the first place? If you follow the link I posted to Twitter Development Talk, you can see that you are not the only one having the problem with error 500. I don't know why this is the case ... * Perhaps the twitter api documentation is not good enough at this point * Maybe we all make the same mistake * Maybe there is only a blank too much in our request headers (which is ok for most http-servers, but not for twitter) * ... Even after hours of trying I don't know ... So if there is no good reason against it, please post your solution to Twitter Development Talk, so we all can learn. Regards, Mitchel
[twitter-dev] Re: API profile image update
One more related question: Is it possible to use oauth for these profile image endpoints? The issue is signing the POST body which the spec does not specify. Does twitter support this in anyway or is basic auth the only option? Josh
[twitter-dev] Re: API profile image update
Okay I've seem to have fixed the code and it works perfectly now. :) Made a few mistakes which where causing the issues and the 500 error. Anyone else experiencing the 500 error should check their code. On Tue, Aug 18, 2009 at 2:37 PM, Josh Roesslein wrote: > Here is the code where I pack the image to send to twitter: > > http://github.com/joshthecoder/tweepy/blob/1e6485cd2f96f0505139f722603d7b6862ec6a45/tweepy/api.py#L422 > > Perhaps I'm doing something wrong there? > > > On Tue, Aug 18, 2009 at 2:30 PM, Josh Roesslein wrote: > >> Thanks for sharing that link Mitchel. It seems the curl example does work >> just fine, so maybe >> the issue is within my code. Just seems twitter doesn't handle the error >> gracefully. Should be a 4xx >> error being returned if its client issue. >> >> >> On Tue, Aug 18, 2009 at 10:34 AM, Mitchel Berberich wrote: >> >>> >>> Hi Josh, >>> Hi David. >>> >>> I have the same problem over here, too. >>> I'm trying to update the image using java jersey but all I get is >>> error 500. >>> >>> Searching the internet half a day, I also found a previous description >>> of the problem posted in December 2008, but still no solution :-( >>> >>> http://groups.google.com/group/twitter-development-talk/browse_thread/thread/bec5efc1469b1d94 >>> >>> Cheers, >>> Mitchel >>> >> >> >> >> -- >> Josh >> > > > > -- > Josh > -- Josh
[twitter-dev] Re: API profile image update
Here is the code where I pack the image to send to twitter: http://github.com/joshthecoder/tweepy/blob/1e6485cd2f96f0505139f722603d7b6862ec6a45/tweepy/api.py#L422 Perhaps I'm doing something wrong there? On Tue, Aug 18, 2009 at 2:30 PM, Josh Roesslein wrote: > Thanks for sharing that link Mitchel. It seems the curl example does work > just fine, so maybe > the issue is within my code. Just seems twitter doesn't handle the error > gracefully. Should be a 4xx > error being returned if its client issue. > > > On Tue, Aug 18, 2009 at 10:34 AM, Mitchel Berberich wrote: > >> >> Hi Josh, >> Hi David. >> >> I have the same problem over here, too. >> I'm trying to update the image using java jersey but all I get is >> error 500. >> >> Searching the internet half a day, I also found a previous description >> of the problem posted in December 2008, but still no solution :-( >> >> http://groups.google.com/group/twitter-development-talk/browse_thread/thread/bec5efc1469b1d94 >> >> Cheers, >> Mitchel >> > > > > -- > Josh > -- Josh
[twitter-dev] Re: API profile image update
Thanks for sharing that link Mitchel. It seems the curl example does work just fine, so maybe the issue is within my code. Just seems twitter doesn't handle the error gracefully. Should be a 4xx error being returned if its client issue. On Tue, Aug 18, 2009 at 10:34 AM, Mitchel Berberich wrote: > > Hi Josh, > Hi David. > > I have the same problem over here, too. > I'm trying to update the image using java jersey but all I get is > error 500. > > Searching the internet half a day, I also found a previous description > of the problem posted in December 2008, but still no solution :-( > > http://groups.google.com/group/twitter-development-talk/browse_thread/thread/bec5efc1469b1d94 > > Cheers, > Mitchel > -- Josh
[twitter-dev] Re: API profile image update
Hi Josh, Hi David. I have the same problem over here, too. I'm trying to update the image using java jersey but all I get is error 500. Searching the internet half a day, I also found a previous description of the problem posted in December 2008, but still no solution :-( http://groups.google.com/group/twitter-development-talk/browse_thread/thread/bec5efc1469b1d94 Cheers, Mitchel
[twitter-dev] Re: API profile image update
Thanks David. So it seems to be a twitter issue not our code. I guess I'll just wait a bit until it gets fixed. On Mon, Aug 17, 2009 at 3:51 PM, David Carson wrote: > > Hi Josh, > > I spent yesterday trying to implement profile image updating for the > first time, with no result other than 500 errors - see > > http://groups.google.com/group/twitter-development-talk/browse_thread/thread/4fe78c5c7fb5cbdf > for my post on the subject. > > Cheers, > David... > -- Josh
[twitter-dev] Re: API profile image update
Hi Josh, I spent yesterday trying to implement profile image updating for the first time, with no result other than 500 errors - see http://groups.google.com/group/twitter-development-talk/browse_thread/thread/4fe78c5c7fb5cbdf for my post on the subject. Cheers, David...