3

Vine Vineにメディアをアップロードする必要があるアプリに取り組んでいます。以下のAPIを試してみましたが、ログインに成功しました。

NSString *abcd=[NSString stringWithFormat:@"https://api.vineapp.com/users/authenticate"];
    NSURL *url = [NSURL URLWithString:abcd];
    NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL: url];
    [request1 setURL:url];
    [request1 setHTTPMethod:@"POST"];

    NSString *stringBoundary = @"0xKhTmLbOuNdArY---This_Is_ThE_BoUnDaRyy---pqo";
    NSString *headerBoundary = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",
                                stringBoundary];
    [request1 addValue:headerBoundary forHTTPHeaderField:@"Content-Type"];
    NSMutableData *postBody = [NSMutableData data];
      // final boundary
    [postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[@"Content-Disposition: form-data; name=\"username\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[@"myuser" dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];

    [postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[@"Content-Disposition: form-data; name=\"password\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[@"pass" dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[[NSString stringWithFormat:@"--%@--\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [request1 setHTTPBody:postBody];

    NSError *error;
    NSURLResponse *response;
    urlData = [NSURLConnection sendSynchronousRequest:request1 returningResponse:&response error:&error];
    NSString *responseString = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
     NSLog(@"responseString..:%@",responseString);
    if (urlData!=nil) {
        if(NSClassFromString(@"NSJSONSerialization"))
        {
            NSError *error = nil;
            id object = [NSJSONSerialization
                         JSONObjectWithData:urlData
                         options:0
                         error:&error];

            if(error) {  }
            if([object isKindOfClass:[NSDictionary class]])
            {
                NSDictionary *results = object;
                  NSLog(@"results..:%@",results);
            }
        }
    }
}

ログインプロセスに関するこのドキュメントを読みました。つる API リファレンス

しかし、ログアウトを実装してメディア API をアップロードすることができません。

誰か提案があれば教えてください。また、つるにビデオを投稿する正しい方法なのか、それとも他の API やライブラリが利用できるのか教えてください。

前もって感謝します。

4

1 に答える 1

-1

ビデオをアップロードするにはpostメソッドを実装し、ログアウトするにはdeleteメソッドを実装する必要があります。質問では、getメソッド呼び出しを実装していると述べています。そのため、API に応じてメソッド タイプを Delete、Post、Get に変更します。

于 2014-04-01T09:45:20.327 に答える