iOS Facebook中的超链接
我需要分享到Facebook的链接。当用户按下该链接时,应将用户带到另一页 我尝试了下面的代码..但它只共享字符串..它的行为不像超级链接iOS Facebook中的超链接,ios,iphone,objective-c,facebook,Ios,Iphone,Objective C,Facebook,我需要分享到Facebook的链接。当用户按下该链接时,应将用户带到另一页 我尝试了下面的代码..但它只共享字符串..它的行为不像超级链接 -(void)fbShare { [hud show:YES]; NSString *title=[NSString stringWithFormat:@"www.google.com"]; MAAppDelegate *appdelegate = (MAAppDelegate *)[[UIApplication sharedAppl
-(void)fbShare
{
[hud show:YES];
NSString *title=[NSString stringWithFormat:@"www.google.com"];
MAAppDelegate *appdelegate = (MAAppDelegate *)[[UIApplication sharedApplication] delegate] ;
if (!appdelegate.session) {
appdelegate.session = [[FBSession alloc]initWithPermissions:[NSArray arrayWithObjects:@"publish_stream",nil]];
}
if (![appdelegate.session isOpen]) {
[appdelegate.session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (!error) {
[self Share:title];
}else {
NSLog(@"facebook errror %@",error.description);
[hud hide:YES];
}
}];
} else {
[self Share:title];
}
}
-(void)Share:(NSString *)text
{
MAAppDelegate *appdelegate = (MAAppDelegate *)[[UIApplication sharedApplication] delegate];
UIImage *image = [UIImage imageNamed:@"bath3.png"];
[FBSession setActiveSession:appdelegate.session];
NSData *dataImage=UIImageJPEGRepresentation(image,1.0);
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:text, @"name", dataImage, @"picture", @"image/png", @"content_type", nil];
FBRequest *request=[FBRequest requestWithGraphPath:@"me/photos" parameters:parameters HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSLog(@"Success");
[hud hide:YES];
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Audalize POC" message:@"Shared Successfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
} else {
[hud hide:YES];
NSLog(@"failed %@",error.localizedDescription);
}
}];
}
请阅读以下内容:
您需要使用“链接”键来共享到facebook的链接
例:
[NSMutableDictionary dictionaryWithObjectsAndKeys:text,@“link”,//<----
数据图像,@“图片”,
@“图像/png”,@“内容类型”
,无];
[NSMutableDictionary Dictionary WithObjectsSandKeys:@“guys”、@“name”、dataImage、@“picture”、@“image/png”、@“content_type”、nil];
[NSMutableDictionary dictionaryWithObjectsAndKeys:text,@"link", // < ----
dataImage,@"picture",
@"image/png",@"content_type"
,nil];