簡體   English   中英

在Facebook上發布圖片?

[英]Image Post on Facebook?

在我的應用程序中。 我成功在我的Facebook牆上張貼了一個圖像(圖像類型為JPEG類型)。 在Simulator和Device中也可以正常工作。

但是問題是,當我從iPhone捕獲圖像或從庫中選擇由照相機捕獲的圖像時。 它沒有發布在Facebook牆上。

另一方面,當我從我的iPhone庫中選擇任何jpeg圖像(通過互聯網下載)時。 它張貼在牆上。

我認為圖像格式存在問題。 請引導我

謝謝

我的代碼在這里。

-(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];


}

我的猜測是您在錯誤的屬性中傳遞了圖像:

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

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

然后確保實現Facbook請求的委托以檢查圖像是否已上傳。

使用圖譜API時,您無法直接發送UIImage ,需要發送UIImageNSData表示形式:

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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM