Facebook分享使用图形api照片与文本不woking

时间:2017-03-30 15:39:33

标签: ios objective-c facebook facebook-graph-api

我正在使用Graph API与文本共享多张照片,我正在使用“public_actions”在帖子中分享照片和文字,但我面临此错误

  

错误域= NSURLErrorDomain代码= -1002“不支持的URL”UserInfo = {NSLocalizedDescription =不支持的URL,NSUnderlyingError = 0x60800045da30 {错误域= kCFErrorDomainCFNetwork代码= -1002“(null)”}}

任何人都可以帮我解决这个错误吗? 我正在关注此Link

以下是我的代码

 if ([FBSDKAccessToken currentAccessToken] != nil) {

    if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) {
           FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                                  initWithGraphPath:@"/me/photos"
                                                  parameters:@{ @"url": exercise.exerciseImageUrl,@"caption": @"test messages",@"published": @"false",}
                                                  HTTPMethod:@"POST"];
                    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                        // Insert your code here

                        NSLog(@"%@",result);

                        if ([result objectForKey:@"id"] != nil) {
                            //[idArray addObject:[result objectForKey:@"id"]];
                            [dict1 setObject:[result objectForKey:@"id"] forKey:@"media_fbid"];
                        }


                        if (arrayTotalImages.count == dict1.count) {
                            NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
                            [dict setObject:dict1 forKey:@"attached_media[0]"]; // add 5 images 
                            [dict setObject:@"Test" forKey:@"message"];

                            FBSDKGraphRequest *request1 = [[FBSDKGraphRequest alloc]
                                                           initWithGraphPath:@"/me/feed"
                                                           parameters:dict
                                                           HTTPMethod:@"POST"];
                            [request1 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                                // Insert your code here

                                NSLog(@"%@",result);

                            }];
                        }

                    }];

    }
}

0 个答案:

没有答案