用于像 Facebook 一样在墙上张贴的 Google 加 API [英] Google plus API for posting on wall like Facebook

查看:17
本文介绍了用于像 Facebook 一样在墙上张贴的 Google 加 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在 google 上搜索教程,以便在 google plus 上发布一些文字.但似乎没有.
我还尝试浏览谷歌为 mac 和 iPhone 开发人员提供的文档,但找不到可以解决我的问题的任何内容.此外,关于如何让用户登录 google plus 帐户的信息也很少.

I have been searching for tutorials on google for posting some text on google plus. But it seems like there are none.
I have also tried to go through the docs provided by google for developers of mac and iPhone but can't find anything that will solve my problem. Also there are little information on how to get the user login to there google plus account.

我不确定用户登录时该怎么做,我是否必须使用一些 GTLObject 或使用 UIWebView 像 Foursquare 来进行用户登录.

I am not sure what to do for the user login, do I have to use some GTLObject or use UIWebView like foursquare for user login.

这是我浏览过的文档列表.

Here is a list of docs that I had went through.

http://code.google.com/p/google-api-objectivec-client/wiki/简介
http://code.google.com/p/google-api-objectivec-client/wiki/BuildingTheLibrary
http://code.google.com/p/gtm-oauth2/>

推荐答案

事实证明只有有限数量的 api 可供 google + 开发人员使用,而且根据 google + page my问题不会得到任何明确的答案,因为 google 正在创建新的 api 以访问 google plus 上的用户信息.

As it turns out there are only a limited number of api's available for google + developers and that also only as GET calls according to the developer of google + page my question will not get any definite answers as google is in the process of creating new api's for accessing user information on google plus.

https://developers.google.com/+/api/

您也可以使用由 google 提供的 google 客户端 sdk,但显示用于用户登录的 webview 会容易得多.我设法从 google plus 获取人员列表.

Also you can use the google client sdk provided by google but it is much easier to show a webview for user login. I managed to get the people list from google plus.

步骤与在foursquare中获取访问令牌的步骤相同.只是做了一些小改动.

The steps are same as for getting the access token as in foursquare. Just with some small changes.

viewdidload 方法中.

NSString *authStr = @"https://accounts.google.com/o/oauth2/auth?client_id=client_id&redirect_uri=http://somevalidurl.com&scope=https://www.googleapis.com/auth/plus.me&response_type=token";

作为在 webview 中加载请求的 url.人们应该在这里注意一件事,您需要在 api 控制台中为基于 Web 的应用程序创建一个客户端 ID,而不是为此目的而安装,因为您不会获得任何选项来输入任何网站 url 进行回调,这在这种情况.

as a url for loading request in webview. People should note one thing here that you need to create a client id in api console for your app that is web based and not as installed for this purpose as you wont we getting any option to enter any website url for callback which is very important in this case.

和在 webview 委托方法 webViewDidFinishLoad:

and in webview delegate method webViewDidFinishLoad:

NSString *urlStr = [[webView.request URL] absoluteString];
NSArray *array = [urlStr componentsSeparatedByString:@"access_token="];
if(array.count > 1)
{
    NSString *oauth_token = [[[array objectAtIndex:1] componentsSeparatedByString:@"&"] objectAtIndex:0];
    //do something with the oauth token after this.
}

这篇关于用于像 Facebook 一样在墙上张贴的 Google 加 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆