-(void)reqUInfo{
NSURL *url=[NSURL URLWithString:@"http://api.tumblr.com/v2/user/info"];
OAMutableURLRequest *request=[[OAMutableURLRequest alloc] initWithURL:url consumer:_consumer token:_accessToken realm:nil signatureProvider:nil];
[request setHTTPMethod:@"POST"];
OADataFetcher *fetcher=[[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request delegate:self
didFinishSelector:@selector(reqUInfoTicket:didFinishWithData:)
didFailSelector:@selector(reqUInfoTicket:didFailWithError:)];
}
- (void)reqUInfoTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data{
NSDictionary *bd=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
shtname=[bd valueForKeyPath:@"response.user.name"];
}
- (void)reqUInfoTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *)error{
NSLog(@"reqUInfo Error! %@",error);
}
- (void)rblg{
NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"http://api.tumblr.com/v2/blog/%@.tumblr.com/post/reblog",shtname]];
OAMutableURLRequest *request=[[OAMutableURLRequest alloc] initWithURL:url consumer:_consumer token:_accessToken realm:nil signatureProvider:nil];
[request setHTTPMethod:@"POST"];
NSString *idstr=[NSString stringWithFormat:@"%lld",[[idArr objectAtIndex:now-1]longLongValue]];
NSMutableArray *prmt=[NSMutableArray arrayWithObject:[[OARequestParameter alloc]initWithName:@"id" value:idstr]];
[prmt addObject:[[OARequestParameter alloc]initWithName:@"reblog_key" value:[NSString stringWithFormat:@"%@",[rblgkArr objectAtIndex:now-1]]]];
//[prmt addObject:[[OARequestParameter alloc]initWithName:@"comment" value:@"comment"]];
[request setParameters:prmt];
OADataFetcher *fetcher=[[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request delegate:self
didFinishSelector:@selector(rblgTicket:didFinishWithData:)
didFailSelector:@selector(rblgTicket:didFailWithError:)];
}
- (void)rblgTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data{
NSDictionary *bd=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
if([[bd valueForKeyPath:@"meta.status"]intValue]==201){
NSLog(@"rebloged.");
}
else NSLog(@"failed.");
}
- (void)rblgTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *)error{
NSLog(@"rblg Error! %@",error);
}
できた。あとはメッセージング処理をやるか。
0 件のコメント:
コメントを投稿