@property (nonatomic, strong) NSURLSessionDataTask *sessionTask;
NSString *strToken = [NSString stringWithFormat:@"Bearer %@",setTokenhere];
NSString * strUrl = [NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/videos/rate?&id=%@&rating=like",setVideoId];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
AFHTTPRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer];
[requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[requestSerializer setValue: strToken forHTTPHeaderField:@"Authorization"];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = requestSerializer;
__weak __typeof(self) weakSelf = self;
self.sessionTask = [manager POST:strUrl parameters:self.parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject)
{
NSLog(@"responseObject -> %@",responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
weakSelf.sessionTask = nil;
NSLog(@"%@",error);
}];
此代碼爲視頻一樣