【发布时间】:2011-11-22 09:21:10
【问题描述】:
我需要将用户帖子从我的 iphone 应用程序分享到 google+。我做了脸书和推特分享。
google+ 是否有用于此的 API?有人有例子吗?
【问题讨论】:
标签: iphone objective-c google-plus
我需要将用户帖子从我的 iphone 应用程序分享到 google+。我做了脸书和推特分享。
google+ 是否有用于此的 API?有人有例子吗?
【问题讨论】:
标签: iphone objective-c google-plus
以下是 Google plus API 的链接: https://developers.google.com/+/api/
& 这里是你可以在 google plus 中找到分享帮助的链接 http://code.google.com/p/google-api-objectivec-client/wiki/Introduction
【讨论】:
对于 Swift 3.0
import SafariServices
然后添加委托
<SFSafariViewControllerDelegate>
在分享按钮中使用下面的代码
var urlComponents = URLComponents(string:"https://plus.google.com/share")
let queryItem = URLQueryItem(name: "url", value: "https://myexamplepagetoshare.com")
urlComponents?.queryItems = [queryItem]
let url = urlComponents?.url
let safariVC = SFSafariViewController(url: url!)
safariVC.delegate = self
self.present(safariVC, animated: true, completion: nil)
这是现在可用的简单 G+ 分享。
【讨论】:
在 google plus 上分享帖子的最简单方法是首先将其 GPPShare.h 文件包含在 xcode 中,然后使用 GPPShareDelegate 扩展 .h 文件 然后在IBAction方法中写这段代码
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
// This line will manually fill out the title, description, and thumbnail of the
// item you're sharing.
[shareBuilder setTitle:@"Share" description:@"sharing" thumbnailURL:[NSURL URLWithString:@"http://25.media.tumblr.com/tumblr_m9p3n1vJmZ1rexr16o1_400.jpg"]];
[shareBuilder setContentDeepLinkID:@"rest=1234567"];
[shareBuilder open];
并实现 GPPShareDelegate 方法,该方法有助于检测成功共享
- (void)finishedSharing:(BOOL)shared
{ if (shared) {
NSLog(@"User successfully shared!");
} else {
NSLog(@"User didn't share.");
}
【讨论】:
目前我认为他们没有任何 API。他们很快就会推出。希望对您有所帮助。 但不是现在。
【讨论】:
您使用 Google+ 分享链接: https://developers.google.com/+/plugins/share/#sharelink
“共享链接适用于本机客户端应用程序...和 其他可能无法使用 +1 或分享按钮的人”
【讨论】:
我集成了 Google plus 分享功能。请查看此代码。 https://www.dropbox.com/s/o0bwtzgbpobsjkq/Share.zip?dl=0
【讨论】: