我想发布一个字符串到我的iphone应用程序的facebook墙上,例如..在facebook上分享状态。如何在脸书上分享状态iphone应用
目前我正在做like..when我登录后按下按钮,我得到一个webview与我想发布的字符串,并与按钮'后'和'取消'。
但我想要..当我只点击第一个按钮(登录后,与facebook webview)字符串应贴到墙上。
我想发布一个字符串到我的iphone应用程序的facebook墙上,例如..在facebook上分享状态。如何在脸书上分享状态iphone应用
目前我正在做like..when我登录后按下按钮,我得到一个webview与我想发布的字符串,并与按钮'后'和'取消'。
但我想要..当我只点击第一个按钮(登录后,与facebook webview)字符串应贴到墙上。
你检查了http://developers.facebook.com/docs/guides/mobile? Facebook有一个你需要的SDK。
添加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];
}
}
是..我看到了。但要发布一个字符串,它会显示带有文本框和按钮的webview以进行发布。但如何做出这个webview和这个按钮...我的意思是,当我们点击按钮,它应该直接发布(与webview) – rockey 2011-01-13 15:47:42