无论我尝试什么,我都无法让我的描述出现在 Facebook 上。我使用了调试器,生成的链接一切正常,并且 URL 填充了适当的数据。图片上传正常,但没有描述。我需要在应用程序的 Facebook 设置中设置什么吗?
以下是相关代码:
- (id<FBPost>)outfitObjectForOutfit{
id<FBPost> result = (id<FBPost>)[FBGraphObject graphObject];
NSString *format =
@"http://mysite.mobi/app/fbOpen.php?"
@"og:title=%@&og:description=%%22%@%%22&"
@"og:caption=%%22%@%%22&"
@"og:image=http://mysite.mobi/images/transBlank.png&"
@"body=%@";
result.url = [NSString stringWithFormat:format,
@"New Post Title",fldDescription.text,fldDescription.text,fldDescription.text];
return result;
}
以及发布到FB的部分:
- (void)postOpenGraphActionWithPhotoURL:(NSString*)photoURL
{
id<FBPost> outfitObject = [self outfitObjectForOutfit];
id<FBPostOutfit> action =
(id<FBPostOutfit>)[FBGraphObject graphObject];
action.outfit=outfitObject;
if (photoURL) {
NSMutableDictionary *image = [[NSMutableDictionary alloc] init];
[image setObject:photoURL forKey:@"url"];
NSMutableArray *images = [[NSMutableArray alloc] init];
[images addObject:image];
action.image = images;
}
[FBSettings setLoggingBehavior:[NSSet
setWithObjects:FBLoggingBehaviorFBRequests,
FBLoggingBehaviorFBURLConnections,
nil]];
NSLog(@"%@",action);
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:fldDescription.text forKey:@"message"];
[FBRequestConnection startForPostWithGraphPath:@"me/appnamespace:action"
graphObject:action
completionHandler:
^(FBRequestConnection *connection, id result, NSError *error) {
NSString *alertText;
if (!error) {
alertText = [NSString stringWithFormat:
@"Posted Open Graph action, id: %@",
[result objectForKey:@"id"]];
} else {
alertText = [NSString stringWithFormat:
@"error: domain = %@, code = %d",
error.domain, error.code];
NSLog(@"%@",error);
}
[[[UIAlertView alloc] initWithTitle:@"Result"
message:alertText
delegate:nil
cancelButtonTitle:@"Thanks!"
otherButtonTitles:nil]
show];
}
];
}