开发者

Posting a photo to Facebook

I am trying very hard to find some sample codes for posting on facebook. Below is the code i found. However, may i know how to modify it in order to me to post a image instead of text ?

FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@ got straight A's!\",\"href\":\"http://www.raywenderlich.com/\",\"caption\":\"%@ must have gotten real lucky this time!\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"http://www.raywenderlich.com/wp-content/themes/raywenderlich/images/logo.png\",\"href\":\"http://www.raywenderlich.com/\"}]}", _facebookName, _facebookName];
dialog.actionLinks = @"[{\"text\":\"Get MyGrades!\",\"href\":\"http://www.raywenderlich.com/\"}]";
[dialog show];

Also the image i am trying to post is a overlapping image. which means it has no file name on it. It is property declared named imageall as the code below.

CGRect subviewFrame3 = [self.comment.superview convertRect:self.comment.frame toView:self.imageall]; [self.imageall addSubview:self.comment]; self.comment.frame = subviewFrame3;

UIGraphicsBeginImageContext(self.imageall.frame.size);
[self.imageall.开发者_开发百科layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsGetCurrentContext();

self.outputView.image = image;

Many thanks.


Here you go

- (void)uploadPhoto:(id)target {

//Just for demonstration.
    NSString *path = @"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg";
    NSURL    *url  = [NSURL URLWithString:path];
    NSData   *data = [NSData dataWithContentsOfURL:url];
    UIImage  *img  = [[UIImage alloc] initWithData:data];
    NSDictionary *params = nil;
    [[FBRequest requestWithDelegate:self] call:@"facebook.photos.upload" params:params dataParam:(NSData*)img];

}


There is a good frame work called "AddThis" to share Images ,links to Facebook,twitter etc (more than 100 social websites).

Look details at AddThis

You can sign-in/sign-up this site and go to AddThis for iOS

This guide will help you get up and running quickly with the iOS SDK. Check out the full documentation for all the details.

Check it the demo application which is embedded with downloaded zip file.

I ensure you that ,this is a good framework to use.

I have implemented it successfully. ask me if you have any queries. Happy coding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜