1

テキストと画像を表示するサンプル プロジェクトを開発しました。Facebook の壁に投稿できます。コードとそのイメージを以下に示しました。これは、ステータス メッセージ付きのウォールに写真を追加する方法のように見えます。

- (IBAction)postStatusUpdateClick:(UIButton *)sender
{
    UIImage *image =[UIImage imageNamed:@"Icon-72@2x.png"];


    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
    [params setObject:@"Test with Image" forKey:@"message"];
    [params setObject:UIImagePNGRepresentation(image) forKey:@"picture"];
    shareOnFacebook.enabled = NO; //for not allowing multiple hits

    [FBRequestConnection startWithGraphPath:@"me/photos"
                                 parameters:params
                                 HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection,
                                              id result,
                                              NSError *error)
     {
         if (error)
         {
             //showing an alert for failure
             [self showAlert:@"Facebook unable to share photo " result:result error:error];
         }
         else
         {
             //showing an alert for success
             [self showAlert:@"Facebook share photo successful" result:result error:error];
         }
         shareOnFacebook.enabled = YES;
     }];
}


// UIAlertView helper for post buttons
- (void)showAlert:(NSString *)message
           result:(id)result
            error:(NSError *)error {

    NSString *alertMsg;
    NSString *alertTitle;
    if (error) {
        alertTitle = @"Error";
        if (error.fberrorShouldNotifyUser ||
            error.fberrorCategory == FBErrorCategoryPermissions ||
            error.fberrorCategory == FBErrorCategoryAuthenticationReopenSession) {
            alertMsg = error.fberrorUserMessage;
        } else {
            alertMsg = @"Operation failed due to a connection problem, retry later.";
        }
    } else {
        NSDictionary *resultDict = (NSDictionary *)result;
        alertMsg = [NSString stringWithFormat:@"Successfully posted '%@'.\nPost ID: %@",
                    message, [resultDict valueForKey:@"id"]];
        alertTitle = @"Success";
    }

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle
                                                        message:alertMsg
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
    [alertView show];
}

ここに画像の説明を入力

*****今、私はFacebookの素晴らしい例のような適切な形式で表示したい.** ここに画像の説明を入力

グラフAPIを開かずにやりたい。誰でもこれで私を助けることができますか

ありがとう

4

2 に答える 2

2

Open Graph API を使用せずに FB ウォールにテキスト付きの画像を投稿する >> http://xcodenoobies.blogspot.com.au/2012/09/how-to-upload-photo-and-update-status.html

更新された回答

FB iOS SDK https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/を使用して Facebook に画像とテキストを投稿する

乾杯、ラヴィ

于 2013-04-11T01:11:38.727 に答える
1

この URL をモバイル サファリで開くだけで、共有ダイアログが表示されます。

    "http://www.facebook.com/dialog/feed?fbapp_id=yorfbappId&name=Test&description=test&redirect_uri=fbyourfbappid%3A%2F%2Fauthorize&sdk=ios"
于 2013-04-10T02:34:32.297 に答える