我想从我的iphone应用程序中将一个字符串发布到Facebook墙上,例如..在Facebook中分享状态。
目前我正在做...当我在登录后按下一个按钮时,我正在使用我要发布的字符串以及按钮“发布”和“取消”获取webview。
但我想...当我点击第一个按钮时(登录后,在facebook webview中),字符串应该贴在墙上。
答案 0 :(得分:1)
您检查了http://developers.facebook.com/docs/guides/mobile吗? Facebook拥有您需要的所有SDK。
答案 1 :(得分:0)
添加Social.Framework,然后添加以下代码
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *FacebookSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeFacebook];
[FacebookSheet setInitialText:@"Your text"];
[FacebookSheet addURL:your url];
[FacebookSheet addImage:[UIImage imageNamed:@"image.png"]];
[FacebookSheet setCompletionHandler:^(SLComposeViewControllerResult result)
{
switch (result)
{
case 0:
{
SLComposeViewControllerResultCancelled:
NSLog(@"Post Canceled");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cancelled"
message:@"You must be connected to the internet to use this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
break;
}
case 1:
{
SLComposeViewControllerResultDone:
NSLog(@"Post Sucessful");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Successful"
message:@"Posted successfully."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
break;
}
default:
break;
}
}];
[self presentViewController:FacebookSheet animated:YES completion:nil];
}
else
{
UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"No facebook accounts" message:@"There are no facebook accounts configured. You can add or create a facebook account in phone settings." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
}