//获取当前时间验证 微博access_token 会否过期
-(BOOL)chackWeiBoAccessToken{
const char* chs=CCUserDefault::sharedUserDefault()->getStringForKey("tmpWeiBoPlayExpirationDate","error").c_str();
self.endTime=[NSString stringWithUTF8String:chs];
if([self.endTime isEqualToString:@"error"]){
[self loginWeibo];
return NO;
}
//创建日期格式化对象
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
//创建了两个日期对象
NSString* nowTime= [dateFormatter stringFromDate:[NSDate date]];
NSDate *dateNow=[dateFormatter dateFromString:[nowTime substringToIndex:16]];
NSDate *dateEnd=[dateFormatter dateFromString:[self.endTime substringToIndex:16]];
double time=[dateEnd timeIntervalSinceDate:dateNow];
if(time<300){ //5分钟后过期,则重新登录
[self loginWeibo];
return NO;
}
return YES;
}