我正在使用应用程序,我必须在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);
}
}
}
}
我已阅读此文档以了解登录过程。Vine API Reference
但我无法实施注销和上传媒体API。
如果有人有任何建议,请告诉我。并告诉我在藤上发布视频是正确的方式,还是有任何其他API或库可用。
提前致谢。
答案 0 :(得分:-1)
你需要实现post方法来上传视频和删除方法来注销。有问题你提到你正在实现get方法调用。因此,根据API将方法类型更改为Delete,Post,Get。