|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59309 Multipart form post
Submitted: 2010-07-15 02:41 UTC Modified: 2010-07-20 18:25 UTC
From: rob dot marscher at gmail dot com Assigned:
Status: Closed Package: oauth (PECL)
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
 [2010-07-15 02:41 UTC] rob dot marscher at gmail dot com
One feature I noticed to be missing from the 1.0 release is support for multipart form post requests.  This is required for updating your background image or logo using the twitter api.  It seems that Twitter is pointing people to this example in ruby that works:

So following this convention, we'd need to check for parameter names beginning with an @ symbol (see the example in the reproduce code section below).  Those parameters would not be included in the signature.  The php curl extension automatically imports the data for a parameter value that contains a filename preceded by an @ symbol.  We'd also have to do something similar here and set the CURLOPT_HTTPPOST option.

There's a php implementation over here  Look at the isMultipart, prepareParameters, and httpPost methods in particular.

My apologies in advance if this isn't the correct place to report this.  I didn't see a discussion group for this extension where I could ask about it first.  I love to see this extension continue to be the "de facto standard" - so I hope we can get this feature added.  I'm sure the Twitter API isn't the only one that needs it (I saw mention on a discussion, at least -

Reproduce code:
// assumptions:
//     - $oauth is an instance of OAuth with access token configured
//     - /home/me/bg.jpg is the background image file on the local filesystem

$oauth->fetch('', array('@image' => '@/home/me/bg.jpg'), OAUTH_HTTP_METHOD_POST);

// expected result: file data is posted using multipart/formdata, 
// a 20x response code is returned from twitter, 
// and the background image is updated

Expected result:
Expecting that the file data is posted using multipart/formdata, a 20x response code is returned from twitter, and the background image is updated for the twitter account.

Actual result:
Currently, doing this results in a request with
Content-Type: application/x-www-form-urlencoded %40image=%40%2Fhome%2Fme%2Fbg.jpg


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-16 02:57 UTC]
Thanks for the excellent bug report. I took a crack at it in 

I agree with your scheme of appending the "@" to both the 
param + file name which I think helps avoid confusion. It 
only works with the cURL engine at the moment. I've also 
added an example for the Twitter use case you described.

Wrt the dropbox thread, I think this would work there 
too...they don't seem to care what the parameters are 
called, and only respect the filename from the content 

Feel free to close this bug if you think this works for your 
use cases.

- JJ
 [2010-07-19 14:28 UTC] rob dot marscher at gmail dot com
Wow!  Thanks for the speedy response and I apologize it took 
me this long to try it out.

Unfortunately, the updateBackgroundImage.php in the examples 
is returning a 401 "Incorrect signature" error from Twitter.  
I'm going to see if I can figure it out.

Also, I'm not sure if this is related to the changes you 
made for this or not, but the fetchTimeline.php example is 
now returning a 500 error with an html response from 
twitter.  The updateStatus.php example still works 

I started debugging the issue and comparing to results using 
the 1.0.0 release version of the extension.  And then I saw 
this message from Twitter:
update-profiles  "We?re currently working on remedying the 
issue blocking users from updating their profiles."  Doh!  
Guess this isn't a good day to test it out.

I'll try again after Twitter fixes their bugs and will post 
my findings here.
 [2010-07-20 18:23 UTC] rob dot marscher at gmail dot com
Twitter claims that the issues are resolved.  I actually got 
it to work once! However, every other attempt gives me a 503 
Service Unavailable error (with an html body with 'Twitter / 
Over capacity' in the title).  Anyway, I think the problem is 
with Twitter so I'm going to close this request.  Thank you so 
 [2010-07-20 18:25 UTC] rob dot marscher at gmail dot com
Closing as feature has been added in trunk.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Oct 01 09:01:24 2023 UTC