2015-10-17 4 views
13

私がやっていることはうまくいかず、次のようなことが起こります:Facebookの共有者を使って私のchoiseのイメージとFacebookのURLを投稿してください。両方の画像をアップロードするにはうまくいかず、画像+テキストとうまく動作します。テキスト+画像+ URLを組み合わせると、アップロードされた画像ではなくURLから画像が取得されます。助言がありますか?私はiOS9でこれをやっていますSLComposeViewControllerは画像とURLの両方を投稿します。

UIImage *tableViewScreenshot = [tblFeed screenshotOfCellAtIndexPath:idx]; 

    SLComposeViewController *fbSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
    [fbSheet setInitialText:@"I need your vote"]; 
    [fbSheet addURL:[NSURL URLWithString:str]]; 
    [fbSheet addImage:tableViewScreenshot]; 
+0

問題はありません。 FB latest api(4.7.x)の問題 –

答えて

2

だから、現時点では解決策が見つかっていないようですが、回避策を見つける必要があります。最初にすべての画像をURLにアップロードしてから、fb sdkを使用してそのURL +リンクオフラインの写真は残念ながらうまくいかないようです。

-1

fbがインストールされていないときに私のiOSアプリケーションでうまく動作しています。私は最新のapi(4.7.x)を使用するためにfbをインストールしましたが、今は共有しません。私はpublish_actionsパーミッションを持っていることを確認しています(私はこのメソッドを呼び出す前に、オープングラフ設定、アクションタイプ、機能を「明示的に共有」しています)。デリゲートは、そのメソッドのどれも呼び出されません取得します。

-(void)shareWithFacebook:(NSString *)message 
{ 
    if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) 
    { 
     NIDINFO(@"Facebook sharing has publish_actions permission"); 
    } 
    else 
    { 
     FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init]; 
     [loginManager logInWithPublishPermissions:@[@"publish_actions"] 
      handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) 
      { 
       NIDERROR(@"Facebook sharing getting publish_actions permission failed: %@", error); 
      } 
     ]; 
    } 

    NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithDictionary: @{ 
                        @"og:type": @"article", 
                        @"og:title": @"Bloc", 
                        @"og:description": message, 
                        @"og:url": @"http://getonbloc.com/download" 
                         }]; 




    FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties]; 

     // Create the action 
    FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"mynamespace:Share" object:object key:@"article"]; 
    [action setString:@"true" forKey:@"fb:explicitly_shared"]; 

     // Create the content 
    FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init]; 
    content.action = action; 
    content.previewPropertyName = @"article"; 

      // Share the content 
    FBSDKShareAPI *shareAPI = [[FBSDKShareAPI alloc] init]; 
    shareAPI.shareContent = content; 
    shareAPI.delegate = self; 

    NSError *error; 
    if([shareAPI validateWithError:&error] == NO) 
    { 
     NIDERROR(@"Facebook sharing content failed: %@", error); 
    } 

    [shareAPI share]; 
} 

#pragma mark - FBSDKSharingDelegate 

- (void) sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results 
{ 
    NIDINFO(@"Facebook sharing completed: %@", results); 
} 

- (void) sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error 
{ 
    NIDERROR(@"Facebook sharing failed: %@", error); 
} 

- (void) sharerDidCancel:(id<FBSDKSharing>)sharer 
{ 
    NIDINFO(@"Facebook sharing cancelled."); 
} 
6

問題は、Facebookが、いくつかの政策を変更され、これにより、デフォルトとして存在するテキストやイメージを持つことができないということです。あなたが見ていない理由ですFacebookのアプリがインストールされているシナリオと、Facebookのアプリがインストールされていないシナリオの2つのシナリオがあります: enter image description here

Facebookアプリがデバイス

enter image description here

にインストールされていない場合

そしてこれは、これは私のコードです:あなたはすべてを共有したい場合はそう

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 

[controller addURL:[NSURL URLWithString:@"https://www.google.com"]]; 
[controller addImage:[UIImage imageNamed:@"icon_circle"]]; 
[controller setInitialText:@"Bhavuk you're great!"]; 

[self presentViewController:controller animated:YES completion:nil]; 

、より有効に活用FB SDK 。

1

残念ながら、問題は単に、たとえば、URLをドロップしても、iOSの請求項10】簡単な回避策に残る:

SLComposeViewController *fbSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
[fbSheet setInitialText:@"I need your vote"]; 
[fbSheet addImage:tableViewScreenshot]; 
+0

initialTextを追加することはできません。現れません。 – Ans

0

それはOPにしかし、あなたは唯一のケアが何であるかの場合は、直接の回答ではありません

SlComposeViewに表示する画像とテキストが、あなたが行っているウェブサイト内に存在する情報と同じ場合は、テキストと画像を表示して何かを共有します。共有する。あなたはiOS側で何か特別なことをする必要は全くありません。

あなたは、また、あなたがURLを共有しているWebページを作成したものですページで、適切なグラフを開くMETAタグを持っている必要がある場合は、タイプフェイスブックのSLComposeViewは、に設定した画像とテキストを表示しますアプリ内のウェブページを自動的に表示します。

Facebook Open Graph Markupに関するいくつかの情報については、 https://developers.facebook.com/docs/sharing/webmasters/#markup