图片发表在Facebook上? [英] Image Post on Facebook?

查看:97
本文介绍了图片发表在Facebook上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序我成功地在我的Facebook墙上张贴图像(图像类型JPEG类型)。在Simulator和Device中也可以正常工作。



但问题是当我从iPhone捕获图像或从相机中捕获的图片中选择一个图像。当我从iPhone图书馆中选择任何jpeg图像(由互联网下载)时,不会在Facebook墙上发布。



它贴在墙上。



在我看来,存在图像格式问题。请指导我



谢谢



我的代码在这里。

   - (IBAction)clickButtonClicked 
{
//对于链接文章

NSString * Message = [NSString stringWithFormat:@测试Iphone应用程序:\http://www.google.com\];


DataClass * obj = [DataClass getInstance];

UIImage * image = [[UIImage alloc] init];

image = obj.imgFinalImage;

NSMutableDictionary * params1 = [[NSMutableDictionary alloc] init];


[params1 setObject:image forKey:@source];
[params1 setObject:Message forKey:@message];

NSString * post = @/ me / photos;


[[AppDelegate facebook] requestWithGraphPath:post andParams:params1 andHttpMethod:@POSTandDelegate:self];

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@Message!消息:@邀请发送成功委托:self cancelButtonTitle:@OKotherButtonTitles:nil];
[alert show];
[alert release];


}


解决方案

p>我的猜测是,您将图像传递给错误的属性:

  NSMutableDictionary * params = [NSDictionary dictionaryWithObjectsAndKeys:
sobj.imgFinalImage,@picture,
Message,@caption,
nil];

[[appDelegate facebook] requestWithMethodName:@photos.upload
andParams:params
andHttpMethod:@POST
andDelegate:self];

然后确保实现Facbook请求的委托以检查图像是否上传。 >

使用图形API,您不能直接发送 UIImage ,您需要发送 NSData 代表 UIImage

  NSMutableDictionary * params1 = [[NSMutableDictionary alloc] init]; 
NSData * imageDate = UIImagePNGRepresentation(obj.imgFinalImage);

[params1 imageDate forKey:@source];
[params1 setObject:Message forKey:@message];

NSString * post = @/ me / photos;


[[AppDelegate facebook] requestWithGraphPath:post andParams:params1 andHttpMethod:@POSTandDelegate:self];


In my application. I successfully post a image on my Facebook wall (image type JPEG Type). It's work fine in Simulator and and Device also.

But the problem is that When I Capture Image from my iPhone or select an image from library which is captured by camera. It is not Posted on Facebook Wall.

on other hand when i choose any jpeg image (downloaded by internet) from my iPhone library. It post on wall.

In my opinion there is image format problem. Please Guide me

Thanks

My code is here.

-(IBAction)clickButtonClicked
{
//    For link post

NSString *Message = [NSString stringWithFormat:@"Testing Iphone App : \"http://www.google.com\" "];    


DataClass *obj=[DataClass getInstance]; 

UIImage *image=[[UIImage alloc]init ];

image= obj.imgFinalImage;

NSMutableDictionary *params1 = [[NSMutableDictionary alloc]init];


[params1 setObject:image forKey:@"source"];
[params1 setObject:Message forKey:@"message"];

NSString *post=@"/me/photos";


[[appDelegate facebook] requestWithGraphPath:post andParams:params1 andHttpMethod:@"POST" andDelegate:self];

UIAlertView  *alert = [[UIAlertView alloc] initWithTitle:@"Message!" message:@"Invitation Send Sucessfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];


}

解决方案

My guess is that you pass the image in the wrong property:

NSMutableDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                    sobj.imgFinalImage, @"picture",
                    Message, @"caption",
                     nil];

[[appDelegate facebook] requestWithMethodName:@"photos.upload"
                   andParams:params
                   andHttpMethod:@"POST"
                  andDelegate:self];

Then make sure you implement the delegate of Facbook request to check if the image is uploaded.

With the graph API you can't send a UIImage directly, you need to send the NSData representation of the UIImage:

NSMutableDictionary *params1 = [[NSMutableDictionary alloc]init];
NSData *imageDate = UIImagePNGRepresentation(obj.imgFinalImage);

[params1 imageDate forKey:@"source"];
[params1 setObject:Message forKey:@"message"];

NSString *post=@"/me/photos";


[[appDelegate facebook] requestWithGraphPath:post andParams:params1 andHttpMethod:@"POST" andDelegate:self];

这篇关于图片发表在Facebook上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆