2015-01-14 33 views
0

我想爲我的ios應用程序創建一個簡單的共享功能。我想利用新的共享對話框(好處,標記好友,添加地點,ecc ..)。我想分享的是一張照片,一個鏈接到iTunes應用程序的下載,一個來自ios應用程序的描述。我曾嘗試sharedialog,像這樣:Fb分享對話框,我是否可以簡單地發表帶有描述的圖片?

NSURL *url=[[NSURL alloc] initWithString:@"https://itunes.apple.com/it/app/myapplication"]; 
[FBDialogs presentShareDialogWithLink:url name:@"My app name" caption:@"" description:@"prefilled descriptiontest" picture:[NSURL URLWithString:@"http://www.example.com/image.jpg"] clientState:nil handler:^(FBAppCall *call, NSDictionary *results, NSError *error) { 
    if(error) { 
     // An error occurred, we need to handle the error 
     // See: https://developers.facebook.com/docs/ios/errors 

     UIAlertView *av = [[[UIAlertView alloc] 
          initWithTitle:@"Sorry :(" 
          message:@"There's been a problem publishing your message. Please try again!" 
          delegate:self 
          cancelButtonTitle:@"Close" 
          otherButtonTitles:nil] autorelease]; 
     [av show]; 

    } else { 
     // Success 

     UIAlertView *av = [[[UIAlertView alloc] 
          initWithTitle:@"Published!" 
          message:@"Your post has been successfully published." 
          delegate:self 
          cancelButtonTitle:@"Close" 
          otherButtonTitles:nil] autorelease]; 
     [av show]; 
    } 
}]; 

它的工作原理,但我看到我的預充式的描述只股價對話框,當我看到在Facebook上共享的內容,我只看到鏈接頁面進行的描述。所以我曾經嘗試這樣做其他的解決方案,photodialog:

UIImage *Image=[UIImage imageNamed:@"myphoto.jpg"]; 
// Open the image picker and set this class as the delegate 
FBPhotoParams *params = [[FBPhotoParams alloc] init]; 

// Note that params.photos can be an array of images. In this example 
// we only use a single image, wrapped in an array. 
params.photos = @[Image]; 



[FBDialogs presentShareDialogWithPhotoParams:params 
           clientState:nil 
            handler:^(FBAppCall *call, 
               NSDictionary *results, 
               NSError *error) { 
             if (error) { 
              NSLog(@"Error: %@", 
                error.description); 
             } else { 
              NSLog(@"Success!"); 
             } 
            }]; 

這樣我可以張貼在牆上的相片,但是描述的參數似乎是onlyread,我不能設置任何預充式文本。我能做些什麼?有一種方法可以強制在共享鏈接對話框中顯示我的描述文本?或者有一種方法可以在photodialog中設置文本?或者有另一種解決方案

+0

預填是不允許的,請閱讀平臺策略:https://developers.facebook.com/policy/ – luschn

+0

我不要預先填充用戶可以在共享對象上插入的文本,我想在圖像旁邊添加一個描述文本,其中包含名爲description和caption的參數。 – user31929

回答

0

唯一的解決辦法似乎是隻使用網絡回退:

NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           name, @"name", 
           author, @"caption", 
           linkShare, @"link", 
           userImage, @"picture", 
           nil]; 

[FBWebDialogs presentFeedDialogModallyWithSession:nil 
            parameters:parameter 
             handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { 
              if (error) 
              { 
               NSLog(@"Error publishing story: %@", error.description); 
              } 
              else 
              { 
               if (result == FBWebDialogResultDialogNotCompleted) 
               { 
                NSLog(@"User cancelled."); 
               } 
               else 
               { 
                NSDictionary *urlParams = [self parseURLParams:[resultURL query]]; 
                NSLog(@"User login"); 

                if (![urlParams valueForKey:@"post_id"]) 
                { 
                 NSLog(@"User cancelled post."); 

                } 
                else 
                { 
                 NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]]; 
                 NSLog(@"result %@", result); 

                } 
               } 
              } 
            }];  
相關問題