我试图从我的Facebook专辑中读取图片。
这是我用来阅读相册的代码:
- (void)storePhotoIntoCoreDataFromAlbumId:(NSString *)albumId whitAlbumName:(NSString *)albumName
{
if (FBSession.activeSession.isOpen) {
NSString *request = [NSString stringWithFormat:@"/%@/photos",albumId];
[FBRequestConnection startWithGraphPath:request
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
if ([result isKindOfClass:[NSDictionary class]]) {
if ([[result valueForKeyPath:@"data"] isKindOfClass:[NSArray class]]) {
NSString *firstPageToRead = [result valueForKeyPath:@"paging.next"];
[self storePicture:[result valueForKey:@"data"] withAlbumTitle:albumName];
if (firstPageToRead) {
[self pagingQueryUntil:firstPageToRead];
}
}
}
} else {
NSLog(@"Errore: %@", error);
}
}
];
}
}
此代码效果很好,它在[pagingQueryUntil:firstPageToRead]
方法中的问题。
我使用这种方法,以防同一张专辑中有很多图片,我不能一次性阅读。
在这种方法中,我将连接到页面以读取其中的图片:
- (void)pagingQueryUntil:(NSString *)until {
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
until, @"until",
nil];
[FBRequestConnection startWithGraphPath:@"/me/photos"
parameters:params
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(@"Errore: %@", error);
}
我收到了这个错误:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0xd092be0 {com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) Must be a unixtime or a date/time representation parseable by strtotime()";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0xd089520, state: FBSessionStateOpen, loginHandler: 0x0, appID: 581914168536264, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0xd1b0960>, expirationDate: 2014-07-19 08:35:28 +0000, refreshDate: 2014-05-20 08:36:52 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
"basic_info",
"user_photos",
installed,
"user_location",
"public_profile",
email,
"user_birthday",
"user_friends",
"friends_photos"
)>}
问题是什么?
答案 0 :(得分:0)
我冒昧地告诉你传递给pagingQueryUntil
的字符串不符合here概述的支持日期和时间格式之一。因此,API会返回您看到的错误:
message = "(#100) Must be a unixtime or a date/time representation parseable by strtotime()";