我正在开发应用程序,我必须在 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。
请如果有人有任何建议,请告诉我。并告诉我在 vine 上发布视频是否正确,或者是否有任何其他 API 或库可供使用。
提前致谢。