1

次のように画像付きのテキストをアップロードしようとしていますFBRequestConnectionが、画像ではなくテキストしかアップロードできません。しかし、img1(image)の代わりに画像リンクを指定すると、Facebookの壁に画像が表示されます。

UIImage *img1 = [UIImage imageNamed:@"Default@2x.png"];

 NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
                                @"https://developers.facebook.com/ios", @"link",
                               img1, @"picture",
                               @"Facebook SDK for iOS", @"name",
                               @"build apps.", @"caption",
                               @"imagae description.", @"description",
                               nil]; 


[params setObject:@"post message" forKey:@"message"];


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

@ "publish_actions"、@​​"user_photos"という2つの許可を取得しました

このコードのどこが間違っているか教えてください。

4

2 に答える 2

4

メッセージ付きのIOSFacebookSDK3アップロード画像で私の答えを確認してください

それはあなたが要求したのと同様の方法です。要件に応じて、さらにいくつかのパラメーターを追加するだけです。

于 2012-10-15T11:47:45.213 に答える
2

@"picture"を@"source"に変更します。新しいFacebook3.1SDKを使用している場合は、次のように簡単に行うことができます。

FBRequest *req = [FBRequest requestForUploadPhoto:img1];
[req.parameters addEntriesFromDictionary:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"post message", @"message", nil]];

FBRequestConnection *con = [[FBRequestConnection alloc] init];
[con addRequest:req completionHandler....
于 2012-10-15T12:02:11.157 に答える