-2

ページウォールに画像を投稿したいのですが、画像をアルバムやユーザーフィードに投稿する方法は知っていますが、ページにはいくつかの問題があります

私は FBGraph API を使用しており、Facebook ページに写真をアップロードしたいのですが、チュートリアルまたはコード ベースへのリンクを提供してください。

現在、投稿したすべての画像は、投稿したいページではなく、ウォールに表示されています。

以下のコードを使用しました

-(void)postPictureToWall
{
    NSMutableDictionary *variables = [[NSMutableDictionary alloc] init];

    // FbGraphFile オブジェクト インスタンスを作成し、公開する画像を設定します
    UIImage *frontImageNew=self.imgvgalleryImage.image;

    FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:frontImageNew];

    //最後に、変数ディクショナリに FbGraphFile オブジェクトを設定します....
    [変数 setObject:graph_file forKey:@"file"];

    NSDateFormatter *df = [[NSDateFormatter alloc]init];
    [df setDateStyle:NSDateFormatterMediumStyle];
    [df setTimeStyle:NSDateFormatterMediumStyle];

    NSString *bodyString=[NSString stringWithFormat:@"%@",[df stringFromDate:[NSDate 日付]]];

    [変数 setObject:bodyString forKey:@"メッセージ"];

 FbGraphResponse *fb_graph_response = [objFBGraph doGraphPost:@"pageid_here/feed" withPostVars:変数];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *facebook_response = [パーサー objectWithString:fb_graph_response.htmlResponse エラー:nil];   
    NSLog(@"fb 応答 = %@",facebook_response);

}

上記のコードを使用して、ページウォールにテキストを正常に投稿していますが、画像は投稿していません

4

1 に答える 1

0

ASIHTTPRequest を使用してそれを行うことができます。私のコードでこれを試してみてください。

-(IBAction)shareClicked:(id)送信者 {

//    if (selectedImage) {
//        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Social Plus"
//                                                       message:@"Please select an image to share"
//                                                      delegate:self
//                                             cancelButtonTitle:@"OK"
//                                             otherButtonTitles:nil];
//        [alert show];
//    }
//    else {
//        

    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"f_selected" ofType:@"png"];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me/photos"]];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
    request.delegate = self;
    [request addFile:filePath forKey:@"file"];
    [request setPostValue:@"here will be the caption" forKey:@"message"];
    [request setPostValue:[[NSUserDefaults standardUserDefaults]objectForKey:@"access_token"] forKey:@"access_token"];
    [request setAllowCompressedResponse:NO];
//    [request setTimeOutSeconds:60];

    [request setDidFinishSelector:@selector(uploadRequestFinished:)];
    [request startAsynchronous];
//    }
}

-(void)uploadRequestFinished:(ASIHTTPRequest *)request
{

    NSString *responseStr = [request responseString];
    NSLog(@"%@",responseStr);
}
于 2012-06-20T10:14:06.817 に答える