0

iOS6 では問題なく機能する関数を追加しましたが、iOS7 では古いものからの id と setId が非公開としてマークされ、検証されていないため、Facebook SDK を更新する必要がありました。そのため、古い SDK を新しいものに置き換えましたが、もちろん、投稿画像は機能しなくなりました (ID が不明であるため)。私はこれを持っていました:

[params setObject:textViewMessageFacebook.text forKey:@"message"];
[params setObject:UIImagePNGRepresentation(screenshot) forKey:@"picture"];

[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos", idAmiS]
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error)

しかし、それを修正して機能させる方法がわかりません...ありがとう

4

1 に答える 1

0

SlComposer Controller を使用して、Facebook に画像を投稿します。

1) まず、ソーシャル フレームワークとアカウント フレームワークをプロジェクトに追加してから、以下のコードを試します。

好きな場所にこのコードを書いてください...

    {
    ACAccountType *facebookTypeAccount = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];


        [accountStore requestAccessToAccountsWithType:facebookTypeAccount
                                               options:@{ACFacebookAppIdKey: @"131740927031850", ACFacebookPermissionsKey: @[@"email"]}
                                            completion:^(BOOL granted, NSError *error) {
                                                if(granted){
                                                    NSArray *accounts = [accountStore accountsWithAccountType:facebookTypeAccount];
                                                    _facebookAccount = [accounts lastObject];
                                                    ACAccountCredential *fbCredential = [_facebookAccount credential];
                                                    accessToken = [fbCredential oauthToken];
                                                    NSLog(@"Facebook Access Token: %@", accessToken);
                                                    NSLog(@"Success");

                                                    [self facebook];
                                                }else{
                                                    NSLog(@"Fail");
                                                    NSLog(@"Error: %@", error);
                                                }
                                            }];

        if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
        {
            SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
            [tweetSheet setInitialText:@"posting from my own app! :)"];
            [tweetSheet addURL:[NSURL URLWithString:@"www.xyz.com"]];


// Here you add the image

             [tweetSheet addImage:[UIImage imageNamed:@"yourimage.png"]];




            [self presentViewController:tweetSheet animated:YES completion:nil];


        }
        else
        {
            UIAlertView *alertView = [[UIAlertView alloc]
                                      initWithTitle:@"Sorry"
                                      message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
                                      delegate:self
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles:nil];
            [alertView show];
        }


    }



    - (void)facebook
    {

        NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
        NSLog(@"URl:-%@",meurl);
        SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                                  requestMethod:SLRequestMethodGET
                                                            URL:meurl
                                                     parameters:nil];

        merequest.account = _facebookAccount;

        [merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
            NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

            NSLog(@"Parsed Data:-%@", meDataString);

        }];

    }
于 2013-10-05T10:58:17.760 に答える