Closed GoogleCodeExporter closed 9 years ago
Ahhhhhhh.. This has been driving me nuts.. I just thought I was stupid and
couldn't
figure out how to set the post method.
Any ETA on when this would be added as I would really like the use the API but
I need
it for POST not just GET.
Original comment by bmcd...@gmail.com
on 25 May 2009 at 6:03
Has anyone managed to execute a POST yet, only needed his API to update twitter
statusus at the moment and that requires a POST, be a shame if i can't do it
now I
have integrated into my app.
Thanks
Manny
Original comment by neil...@gmail.com
on 8 Jun 2009 at 4:12
I have a really quick and dirty solution for this... not the best solution
since I'm not too familiar with the API but
does work for POST calls. Would love to work on the "correct" fix.. just need
a little guidance from the devs.
Original comment by bonc...@gmail.com
on 1 Jul 2009 at 3:23
How can this Issue priority set to Medium? Without POST, this code is not
usable in 99.99% of APIs! Or do I miss
something?
Original comment by martin.d...@gmail.com
on 2 Jul 2009 at 1:47
[deleted comment]
Found "POST" logic already in MPOAuthURLRequest (as indicated by other
posters), so I
altered the following in MPOAuthAPI (not the most elegant, but perhaps least
invasive
to callee methods - note previous deleted post had a defect):
BEFORE:
- (void)performMethod:(NSString *)inMethod atURL:(NSURL *)inURL
withParameters:(NSArray *)inParameters withTarget:(id)inTarget
andAction:(SEL)inAction {
if (!inMethod && ![inURL path] && ![inURL query]) {
[NSException raise:@"MPOAuthNilMethodRequestException" format:@"Nil was passed as
the method to be performed on %@", inURL];
}
NSURL *requestURL = inMethod ? [NSURL URLWithString:inMethod relativeToURL:inURL] :
inURL;
MPOAuthURLRequest *aRequest = [[MPOAuthURLRequest alloc] initWithURL:requestURL
andParameters:inParameters];
AFTER:
- (void)performMethod:(NSString *)inMethod withTarget:(id)inTarget
andAction:(SEL)inAction doPost:(BOOL)inPost {
[self performMethod:inMethod atURL:self.baseURL withParameters:nil
withTarget:inTarget andAction:inAction doPost:inPost];
}
- (void)performMethod:(NSString *)inMethod atURL:(NSURL *)inURL
withParameters:(NSArray *)inParameters withTarget:(id)inTarget
andAction:(SEL)inAction {
[self performMethod:inMethod atURL:inURL withParameters:inParameters
withTarget:inTarget andAction:inAction doPost:NO];
}
- (void)performMethod:(NSString *)inMethod atURL:(NSURL *)inURL
withParameters:(NSArray *)inParameters withTarget:(id)inTarget
andAction:(SEL)inAction doPost:(BOOL)inPost {
if (!inMethod && ![inURL path] && ![inURL query]) {
[NSException raise:@"MPOAuthNilMethodRequestException" format:@"Nil was passed as
the method to be performed on %@", inURL];
}
NSURL *requestURL = inMethod ? [NSURL URLWithString:inMethod relativeToURL:inURL] :
inURL;
MPOAuthURLRequest *aRequest = [[MPOAuthURLRequest alloc] initWithURL:requestURL
andParameters:inParameters];
if (inPost) aRequest.HTTPMethod = @"POST";
Tried the following code, and it appeared to work for me (had compiler warning,
but I
found +parametersFromString defined so I didn't spend much time tracking
down the issue):
NSArray *array = [MPURLRequestParameter parametersFromString:@"status=Mr.
Watson--come here--I want to see you."];
[_oauthAPI performMethod:@"statuses/update.json" atURL:_oauthAPI.baseURL
withParameters:array withTarget:self
andAction:@selector(_confirmPost:withResponseString:) doPost:YES];
Original comment by jason.hu...@gmail.com
on 3 Jul 2009 at 5:52
thanks for this... btw, you can get rid of the complier error if you import
MPURLRequestParameter.h
Original comment by will.car...@gmail.com
on 6 Dec 2009 at 5:30
POST methods added to MPOAuthAPI
Original comment by karl.a...@gmail.com
on 21 Dec 2009 at 9:26
Awesome Karl!
Original comment by martin.d...@gmail.com
on 21 Dec 2009 at 9:30
Although there is a POST method in MPOAuthAPI, seems that MPOAuthURLRequest's
init method will only set its
HTTPMethod to GET thus disregarding the user selected HTTP Method. Is there
something I'm missing with this
API call?
Original comment by adam.ml...@gmail.com
on 1 Mar 2010 at 10:04
lol, you're correct. When I cleaned up the code recently I removed the
originally written method in favor of
sharing the same one for both. The lack of a unit test caused me to miss this.
Now fixed.
Original comment by karl.a...@gmail.com
on 1 Mar 2010 at 10:18
Thanks Karl! Your API is awesome!
I'm working with an API that requires the POST to be of the form
multipart/form-data however I noticed that
your API builds the POST data with urlencoded form. Without changing your API,
what would be the best way to
make it so the HTTPbody is built with with multipart/form-data?
Thanks!
Original comment by adam.ml...@gmail.com
on 1 Mar 2010 at 11:21
You can edit it directly in the MPOAuthURLRequest.m file.
Original comment by karl.a...@gmail.com
on 1 Mar 2010 at 11:27
ok....thanks Karl
Original comment by adam.ml...@gmail.com
on 2 Mar 2010 at 1:45
hey adam,
i put together a multipart post to do image upload for the meetup api. i've
attached
my code so you can check it out. hopefully it helps you out.
-rich
Original comment by rhsieh@gmail.com
on 3 Mar 2010 at 3:20
Attachments:
Original issue reported on code.google.com by
jlee0...@gmail.com
on 30 Apr 2009 at 7:27