How to post photos to facebook iphone fbconnect

穿精又带淫゛_ 提交于 2019-12-19 05:09:41

问题


Hi I'm using FBConnect to post to facebook, now I need to post photos from library or taken with the cam, does anyone has a clue how to do this ?? I've searched in google but I can't find a piece of code that works for me. I've found this method:

FBRequest *uploadPhotoRequest = [FBRequest requestWithDelegate:self];
     [uploadPhotoRequest call:@"photos.upload" params:args];

but in my fbconnect i have this one instead: (I think the version of the api is different)

 [_fbRequest call:(NSString *) params:(NSDictionary *) dataParam:(NSData *)];

Also I'm using this method to post to the wall:

 - (void)postToWall {       FBStreamDialog* dialog = [[[FBStreamDialog
 alloc] init] autorelease];
 dialog.userMessagePrompt = @"Enter your message:";   
 dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ Esta conectado desde TravelFan iPhone App\",\"caption\":\"Viajar te cambia la vida\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.travelfan.com.mx/content/templates/default/images/logo_travel.jpg\",\"href\":\"http://www.travelfan.com.mx/\"}]}",
 _facebookName];   
dialog.actionLinks = @"[{\"text\":\"Obten TravelFan
 App!\",\"href\":\"http://www.travelfan.com.mx/\"}]";   [dialog show];  
 }

In this method I can send an image but not as a photo its just for the app logo and its an attachment.

Can anyone tell how to post photos to the wall pls ?? Any help is apreciated XD.


回答1:


You can now post photos on your wall with requestWithGraphPath method as follows.

NSData *yourImageData= UIImagePNGRepresentation(yourImage);

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"Your text with picture", @"message", yourImageData, @"source", nil];

[facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];



回答2:


The requestWithGraphPath method is non-blocking - meaning it will complete before the photo is actually uploaded. You'll know when the photo is finished uploading by implementing the following in your FBRequestDelegate



来源:https://stackoverflow.com/questions/6959961/how-to-post-photos-to-facebook-iphone-fbconnect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!