11

我正在按照他们的说明使用新的 Facebook SDK 在我的墙上发布

我从应用程序获得了授权,但是当我尝试发布时,我在 Error: HTTP status code: 400下面收到错误,我正在发布我的代码

 - (void)viewDidLoad
{
self.postParams =
 [[NSMutableDictionary alloc] initWithObjectsAndKeys:
 @"https://developers.facebook.com/ios", @"link",
 @"https://developers.facebook.com/attachment/iossdk_logo.png", @"picture",
 @"Facebook SDK for iOS", @"name",
 @"build apps.", @"caption",
 @"testing for my app.", @"description",
 nil]; 

[self.postParams setObject:@"hgshsghhgsls" forKey:@"message"];

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

-(IBAction)Post{
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openSessionWithAllowLoginUI:YES];


[FBRequestConnection   startWithGraphPath:@"me/Mac" parameters:self.postParams HTTPMethod:@"POST"
                        completionHandler:^(FBRequestConnection *connection,id result,NSError *error) {
                            NSString *alertText;
                             if (error) {
                             alertText = [NSString stringWithFormat:@"error: domain = %@, code = %d, des = %d",error.domain, error.code,error.description];
                             } 
                             else 
                             {
                             alertText = [NSString stringWithFormat:@"Posted action, id: %@",[result objectForKey:@"id"]];
                             }
                             // Show the result in an alert
                             [[[UIAlertView alloc] initWithTitle:@"Result" message:alertText delegate:self cancelButtonTitle:@"OK!"
                             otherButtonTitles:nil]show];
                        }]; 




}

我在这里做错了什么,任何建议都会很好,这个新的 SDK 是 beta 版本?还是完整的?

4

4 回答 4

12

如果您遇到任何问题,请尝试通过在您有兴趣调试的请求调用之前添加此代码来打开日志记录:

[FBSettings setLoggingBehavior:[NSSet setWithObjects:FBLoggingBehaviorFBRequests, FBLoggingBehaviorFBURLConnections, nil]];

于 2012-09-19T09:44:11.043 回答
4

最后我解决了这个问题,因为我必须在我的应用权限页面中将 Auth Token Parameter 更改为 URLFragment 然后它正在工作

于 2012-08-30T11:59:43.770 回答
0

检查会话发布权限。

它对我很好。

[FBSession openActiveSessionWithPublishPermissions:[[NSArray alloc] initWithObjects:@"publish_stream",@"email", nil]
                                   defaultAudience:FBSessionDefaultAudienceFriends
                                      allowLoginUI:YES
                                 completionHandler:^(FBSession *session,
                                                     FBSessionState state, NSError *error) {
                                     [self sessionStateChanged:session state:state error:error];
                                 }];
于 2013-04-12T23:24:42.420 回答
0

我在我的项目中使用了这个框架。它工作正常。这是我的相关代码

   -(IBAction)logIn:(id)sender;
{
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (!FBSession.activeSession.isOpen) {
    [appdelegate sessionOpener];
}
else {
    [self loginHelp];
}

我的 sessionOpener 函数是;

 -(void) sessionOpener

{

[FBSession sessionOpenWithPermissions:nil
                    completionHandler:^(FBSession *session,
                                        FBSessionState status,
                                        NSError *error) {
                        // session might now be open.
                        if (!error) {
                            [self.viewController loginHelp];
                        }
                    }];

 NSLog(@"%d", FBSession.activeSession.isOpen);
NSLog(@"%@", FBSession.activeSession.description );

}

这个对我有用。可能对你有帮助。

于 2012-12-29T10:42:40.710 回答