【问题标题】:iPhone App - Google plus share with pre-fill textiPhone 应用程序 - 带有预填充文本的 Google plus 共享
【发布时间】:2012-09-20 08:16:14
【问题描述】:

听说我们可以使用此链接在 Google+ 上分享 https://plus.google.com/share?url=YOUR_URL_HERE

我们如何在“分享/帖子”中添加文字? (就像在 Twitter 中,我可以设置“预填充文本”参数)它的 URL 参数是什么?有人可以帮忙吗?

【问题讨论】:

  • 我正在为 Google+ 和 Facebook 寻找相同的功能
  • 似乎至少没有documented 方法可以做到这一点。

标签: iphone ios


【解决方案1】:

如果您想将您的应用与 Google+ 紧密集成,我建议您使用此处列出的 SDK:https://developers.google.com/+/mobile/ios/

分享一点:https://developers.google.com/+/mobile/ios/#share_on_google

创建您的共享对象:

GooglePlusShare *share =
    [[[GooglePlusShare alloc] initWithClientID:clientID] autorelease];
share.delegate = self; // optional
appDelegate.share = share; //optional

在按钮的 IBAction 中:

- (IBAction) didTapShare: (id)sender {
  // Add code here to retrieve the value of "share"
  // This could be self.share if this is a property of your ViewController
  // or ((MyAppDelegate *)[[UIApplication sharedApplication] delegate]).share

  [[[[share shareDialog]
      setURLToShare:[NSURL URLWithString:@"URL_TO_SHARE"]]
          setPrefillText:@"YOUR TEXT HERE"] open];

  // Or, without a URL or prefill text:
  [[share shareDialog] open];
}

Google+ 网址处理程序:

- (BOOL)application: (UIApplication *)application
              openURL: (NSURL *)url
    sourceApplication: (NSString *)sourceApplication
           annotation: (id)annotation {
  // ...

  if ([self.share handleURL:url
          sourceApplication:sourceApplication
                 annotation:annotation]) {
    return YES;
  }

  // ...
}

【讨论】:

  • +1,我对 URL 太执着了,没想到 SDK。
  • 我确实尝试了他们的 SDK,但我在集成它时遇到了问题(尤其是他们提供的 OpenSource 工具包)。我为此苦苦挣扎了几天,终于转向了使用 URL 的简单方法!
  • 您好,有没有什么方法可以在没有共享对话的情况下在 google+ 上发布帖子..?
【解决方案2】:

我做了一些研究并想出了这个:

也就是说,如果您控制共享页面,您应该能够影响 +1-share-thingy 的内容。如果没有,似乎仍然没有办法这样做。 p>

另外:这个问题似乎与this question asked 2012-02-26 by Vitali Ponomar 几乎完全相同

【讨论】:

  • 它不会预填充帖子/评论的文本。我有一个包含多个事件的页面,我希望用户可以选择一个事件并在 Google+ 或 Facebook 上共享它(只是单个事件,而不是整个页面)。在 FB 和 G+ 上似乎是不可能的,除非我为每个事件创建一个页面。不过,感谢您进行的搜索。
  • @Baldrick 不客气。抱歉,我混淆了 FB 和 Twitter,更正并添加了对文档的引用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多