请参阅页面底部的12月29日更新说明。
嗨,我正在为其他人在工作中的iOS项目做维护工作(因为他们没有记录他们的代码,所以这是一种破坏灵魂的行为。)
问题是,在用户登录后,尝试将帖子共享到墙上总会导致
错误100:“帖子的链接必须指向应用程序的连接或画布网址”。
我搜索过去2个小时并且没有找到专门针对iOS的任何结果(但很多用于wordpress,这没有帮助)
任何可能导致此问题的想法。
以下是发布到墙上的海外开发者代码:
-(void)uploadPropertyDetailsOnFacebookWall
{
[FBSettings setLoggingBehavior:[NSSet setWithObjects:FBLoggingBehaviorFBRequests, FBLoggingBehaviorFBURLConnections, nil]];
NSString* photoURL = @"";
NSString *strFullPropertyDetailLink=@"";
if (!kIsListOnce) {
photoURL = [currentItem objectForKey:@"Photo1FeaturedURL"];
strFullPropertyDetailLink=[currentItem objectForKey:@"FullDisplayLink"];
}
else {
strFullPropertyDetailLink=[currentItem objectForKey:@"FullDisplayLink"];
NSArray* list = [[currentItem objectForKey:@"objects"] objectForKey:@"img_small"];
;
if ([list count] > 0) {
photoURL = [list objectAtIndex:0];
}
}
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSString *strLinkOfApp=(NSString *)[Utils config:KiTunesstoreAppLink]; //strFullPropertyDetailLink,
NSDictionary *postParams =
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
strFullPropertyDetailLink, @"link",
photoURL, @"picture",
[Utils config:kTextAgentName], @"name",
strAddress, @"caption",
[currentItem objectForKey:@"Description"], @"description",
nil];
[FBRequestConnection startWithGraphPath:@"me/feed"
parameters:postParams
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSString *alertText;
NSLog(@"%@",error);
if (error) {
NSDictionary *dict=[error userInfo];
NSLog(@"%@",dict);
NSDictionary *dictJSON=[dict objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"];
NSDictionary *dictBody=[dictJSON objectForKey:@"body"];
NSDictionary *dictError=[dictBody objectForKey:@"error"];
NSString *strCode=[[dictError objectForKey:@"code"] description];
if([strCode isEqualToString:@"200"])
{
alertText = @"You have not authorized the application to perform this publish action";
}else{
alertText = [@"An error ocurred: " stringByAppendingString:error.description];
alertText=[alertText stringByAppendingString: strFullPropertyDetailLink];
}
} else {
alertText = [NSString stringWithFormat:
@"Property details has been successfully shared on your Facebook Wall"];
}
[[[UIAlertView alloc] initWithTitle:@"Result"
message:alertText
delegate:nil
cancelButtonTitle:@"OK!"
otherButtonTitles:nil] show];
// Show the result in an alert
}];
}
以下是我不断收到的错误:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed(com.facebook.sdk error 5.)" UserInfo=0x1d548710 {com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) The post's links must direct to the application's connect or canvas URL.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
2013-08-02 12:06:12.806 RealEstate[385:907] {
"com.facebook.sdk:HTTPStatusCode" = 400;
"com.facebook.sdk:ParsedJSONResponseKey" = {
body = {
error = {
code = 100;
message = "(#100) The post's links must direct to the application's connect or canvas URL.";
type = OAuthException;
};
};
code = 400;
};
}
请帮忙,自从我最初发帖以来,我在网上做了更多的研究,但仍然无法找到答案。
12月17日更新:
我正在使用SDK 3.1.1。我想避免更新,因为我正在维护别人的代码。
在fbrequestconnection中使用me / feed,除了“message”之外的任何其他参数,都会导致应用崩溃。
我还尝试使用其他堆栈溢出用户建议的设置将应用链接到测试帐户viewable here
我也禁用了流媒体后安全性
其他问题
答案 0 :(得分:1)
我一直在努力发布到Facebook墙上。
为什么不使用facebook SDK而不是API? 有两种方法可以使用SDK发布到Facebook墙上
通过Feed Dialog 要么 通过Share Dialog
Feed对话框非常易于实现,您可以通过发送的参数控制要发布的内容,唯一不好的是参数有限。
Share Dialog使用OpenGraph并要求用户安装facebook APP,您还必须在Facebook的app开发者页面中创建一个操作,以便您的应用知道如何处理该操作。 好的部分是你可以分享几乎所有你想要的东西。
我建议您查看Feed对话框,如果您想要一个简单的Facebook分享,这是最简单的方法。
修改
NSString *message = [NSString stringWithFormat:@"%@%@/%@",domain,TypeName,[object alias]];
// Put together the dialog parameters
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
@"TITLE", @"description",
message, @"link",
[object image],@"picture",
nil];
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or publishing a story.
//NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
//NSLog(@"User canceled story publishing.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User clicked the Cancel button
//NSLog(@"User canceled story publishing.");
} else {
// User clicked the Share button
NSString *msg = @"Partilhado com sucesso";
//NSLog(@"%@", msg);
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@"Aviso"
message:msg
delegate:nil
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}
}
}
}];