【发布时间】:2012-07-17 10:18:25
【问题描述】:
我在我的 iPhone 应用程序中在墙上实现 Facebook 发帖时遇到问题。 我安装了 SDK 和链接框架 登录工作正常。这是代码:
-(IBAction)loginButtonPressed:(id)sender
{
NSLog(@"loginButtonPressed: called");
AppDelegate *appdel=[[UIApplication sharedApplication] delegate];
appdel.facebookSession=[[FBSession alloc] init];
[appdel.facebookSession openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
{
//
}];
}
但是我在用户的墙上发布消息时遇到了问题。代码如下:
-(IBAction)likeButtonPressed:(id)sender
{
NSLog(@"likeButtonPressed: called");
// Post a status update to the user's feedm via the Graph API, and display an alert view
// with the results or an error.
NSString *message = @"test message";
NSDictionary *params = [NSDictionary dictionaryWithObject:message forKey:@"message"];
// use the "startWith" helper static on FBRequest to both create and start a request, with
// a specified completion handler.
[FBRequest startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
}];
}
请帮帮我。我的代码有什么问题?还是应该为登录请求添加一些权限?
【问题讨论】:
-
您忘记描述实际的问题/错误。
-
在您发起 Facebook 帖子时是否显示登录表单?
-
我在调试中收到一条消息:
Error: HTTP status code: 400和The operation couldn't be completed. (com.facebook.FBIOSSDK error 5.)in ÙIAlertView` -
@user1385666 我相信这个错误是 "{"error":{"message":"An active access token must be used to query about the current user.","type":"OAuthException ","code":2500}}"
-
我使用 FB SDK + iOS 6 和 Storyboards 在 GitHub 中创建了一个简单的项目作为示例。该应用可以在时间线中发布:FB SDK + Storyboards with Publish to FeedCheers!
标签: iphone objective-c ios facebook