在Facebook墙上iPhone sdk上传照片

时间:2011-06-24 07:16:53

标签: iphone ipad facebook facebook-graph-api

我陷入了奇怪的境地。我想从我的iPad应用程序上传照片,该照片将始终显示在用户的墙上。我已尝试使用“facebook.photo.upload”方法但由于某种原因,它在用户的墙上显示1张照片,而所有其他上传都直接进入相册,并且不会出现在用户的墙上。所以我想在用户的墙上显示所有照片。

所以,另一个场景是我可以使用“stream.publish”并将我的照片附加到附件参数中。但是在这个方法中我需要我没有的UIImage的URL。即使我管理URL仍然我想我的照片将显示为缩略图与所有其他流节目。我希望我的照片保留尺寸768X1004。

那么,在iPhone sdk中实现这一目标的最佳方法是什么。我只是想每次都在用户的墙上上传我的照片。我不介意它是否进入专辑。

先谢谢你的帮助..

修改

我通过将照片上传到我自己的服务器并使用publish.stream将其发布到用户的墙来完成此操作。我没有别的办法。

2 个答案:

答案 0 :(得分:1)

尝试Facebook图形api的这种方法它将在Facebook墙上发布照片

-(IBAction)postPictureButtonPressed:(id)sender {

    NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];

    //create a UIImage (you could use the picture album or camera too)

    NSData *imageData = UIImageJPEGRepresentation(imageView.image, 8.0);
    UIImage *picture = [UIImage imageWithData:imageData];

    //create a FbGraphFile object insance and set the picture we wish to publish on it
    FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];

    //finally, set the FbGraphFileobject onto our variables dictionary....
    [variables setObject:graph_file forKey:@"file"];

    [variables setObject:@"this is a test message: postPictureButtonPressed" forKey:@"message"];

    //the fbGraph object is smart enough to recognize the binary image data inside the FbGraphFile
    //object and treat that is such.....
    FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"117795728310/photos" withPostVars:variables];
    NSLog(@"postPictureButtonPressed:  %@", fb_graph_response.htmlResponse);

    NSLog(@"Now log into Facebook and look at your profile & photo albums...");

}   

答案 1 :(得分:0)

没有得到任何解决方案。所以我通过将照片上传到我自己的服务器并使用publish.stream将其发布到用户的墙上来实现这一目标。我没有别的办法。