简体   繁体   English

使用新的sdk在我的Facebook墙上发布

[英]publishing on my facebook wall using new sdk

I am using the new Facebook SDK to publish on my wall by following their instructions 我正在使用新的Facebook SDK按照他们的指示在我的墙上发布

I got authorization from the app, but when i try to publish i am getting an error Error: HTTP status code: 400 below i am posting my code 我从应用程序获得授权,但当我尝试发布时收到错误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];
                        }]; 




}

What am i doing wrong here and any suggestion will be great and this new SDK is a beta version ? 我在这里做错了什么,任何建议都会很棒,这个新的SDK是测试版? or a complete one ? 还是一个完整的?

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

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

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

i used this framework for my project. 我将这个框架用于我的项目。 it works properly. 它工作正常。 this is my related code 这是我的相关代码

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

and my sessionOpener function is; 而我的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 );

} }

it works for me. 这个对我有用。 may be helpful to you. 可能对你有所帮助。

check Session Publish Permissions. 检查会话发布权限。

its worked me fine. 它对我很好。

[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];
                                 }];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM