1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gtm-oauthとgtm-http-fetcherで添付するときのメモ

Last updated at Posted at 2012-08-29

(1)バイナリ以外の項目

GTMMIMEDocument *doc = [GTMMIMEDocument MIMEDocument];

// keywordはNSString
 NSMutableDictionary *headers
 = [NSMutableDictionary dictionaryWithObject:@"form-data; name=\"keyword\"" forKey:@"Content-Disposition"];
    [doc addPartWithHeaders:headers body:[keyword dataUsingEncoding:NSUTF8StringEncoding]];

// entryTextはNSString
headers = [NSMutableDictionary dictionaryWithObject:@"form-data; name=\"status\"" forKey:@"Content-Disposition"];
 [doc addPartWithHeaders:headers body:[entryText dataUsingEncoding:NSUTF8StringEncoding]];

(2)リクエストにoauth認証の情報を追加するのは一番最後送信直前にする

NSMutableURLRequest *request
 = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"送信先URL"]];
[request setHTTPMethod:@"POST"];
// ::
// いろいろ
// ::
//authはGTMOAuthAuthentication
[auth authorizeRequest:request];
GTMHTTPFetcher *fetcher = [GTMHTTPFetcher fetcherWithRequest:request];
[fetcher setPostStream:stream];
[fetcher beginFetchWithDelegate:self
                      didFinishSelector:@selector(送信したあと)];
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?