2011-01-12 6 views
1

私のような私のiPhoneアプリからFacebookの壁に文字列を投稿したい。Facebookのステータスを共有する。Facebookのフォームでステータスを共有する方法

現在、私はログインした後にボタンを押したときに、私が投稿したい文字列をウェブビューに表示しています。「ポスト」と「キャンセル」ボタンがあります。

しかし、私は最初のボタンをクリックするだけで(ログインした後で、facebook webviewから)文字列を壁に投稿する必要があります。

答えて

1

http://developers.facebook.com/docs/guides/mobileをチェックしましたか? Facebookには、必要なすべてのSDKがあります。

+0

はい下に追加します..私は見ました。文字列をポストするには、テキストボックスと公開するボタンでwebviewを表示します。このWebviewとこのボタンをどうすればいいのか...私はいつでも私たちが直接(ウェブビューではなく)投稿すべきボタンをクリックすることを意味します。 – rockey

+0

http://www.raywenderlich.com/1626/how-to-postユーザーから壁にアップロードされた写真や追加のようなボタンを使って、あなたのiPhoneアプリから私を助けてくれました – rockey

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]; 
      } 
    } 
関連する問題