0

何を試しても、自分の説明が Facebook に表示されません。デバッガーを使用しましたが、生成されたリンクは問題なく、URL には適切なデータが入力されています。写真は問題なくアップロードされていますが、説明がありません。アプリの Facebook 設定で設定する必要があるものはありますか?

関連するコードは次のとおりです。

- (id<FBPost>)outfitObjectForOutfit{

id<FBPost> result = (id<FBPost>)[FBGraphObject graphObject];

NSString *format =
@"http://mysite.mobi/app/fbOpen.php?"
@"og:title=%@&og:description=%%22%@%%22&"
@"og:caption=%%22%@%%22&"
@"og:image=http://mysite.mobi/images/transBlank.png&"
@"body=%@";
result.url = [NSString stringWithFormat:format,
              @"New Post Title",fldDescription.text,fldDescription.text,fldDescription.text];
return result;
}

FB に公開する部分:

    - (void)postOpenGraphActionWithPhotoURL:(NSString*)photoURL
{

id<FBPost> outfitObject = [self outfitObjectForOutfit];

id<FBPostOutfit> action =
(id<FBPostOutfit>)[FBGraphObject graphObject];

action.outfit=outfitObject;

   if (photoURL) {
    NSMutableDictionary *image = [[NSMutableDictionary alloc] init];
    [image setObject:photoURL forKey:@"url"];

    NSMutableArray *images = [[NSMutableArray alloc] init];
    [images addObject:image];

    action.image = images;
}
[FBSettings setLoggingBehavior:[NSSet
                                setWithObjects:FBLoggingBehaviorFBRequests,
                                FBLoggingBehaviorFBURLConnections,
                                nil]];
NSLog(@"%@",action);
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:fldDescription.text forKey:@"message"];
[FBRequestConnection startForPostWithGraphPath:@"me/appnamespace:action"
                                   graphObject:action
                             completionHandler:
 ^(FBRequestConnection *connection, id result, NSError *error) {
     NSString *alertText;
     if (!error) {
         alertText = [NSString stringWithFormat:
                      @"Posted Open Graph action, id: %@",
                      [result objectForKey:@"id"]];
     } else {
         alertText = [NSString stringWithFormat:
                      @"error: domain = %@, code = %d",
                      error.domain, error.code];
         NSLog(@"%@",error);
     }
     [[[UIAlertView alloc] initWithTitle:@"Result"
                                 message:alertText
                                delegate:nil
                       cancelButtonTitle:@"Thanks!"
                       otherButtonTitles:nil]
      show];
 }
 ];
 }
4

1 に答える 1

1

私は自分の問題を理解しました。Facebook の例 (アクティビティの公開) とユーザーのウォールへの公開を混同していました。これを機能させるために私がしなければならなかったのはこれだけでした:

NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:fldDescription.text forKey:@"message"];
[params setObject:UIImagePNGRepresentation(userImage) forKey:@"picture"];

[FBRequestConnection startWithGraphPath:@"me/photos"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error)
 {
     if (error) {

         [[[UIAlertView alloc] initWithTitle:@"Result"
                                     message:@"Sorry there was an error posting to Facebook."
                                    delegate:nil
                           cancelButtonTitle:@"OK"
                           otherButtonTitles:nil]
          show];
     }
 }];

また、アプリの opengraph 設定に移動し、ユーザー メッセージとユーザー生成の写真を許可する必要があることにも言及する必要があります。

于 2013-04-05T19:01:51.917 に答える