Google Plus无法发布片刻 [英] Google Plus can't post a moment

查看:149
本文介绍了Google Plus无法发布片刻的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google授权之后,我尝试发布一段时间,但没有任何确认信息:

  GTMOAuth2Authentication * auth; 
auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:TMH_SOCIAL_GOOGLE_KEYCHAIN
clientID:TMH_SOCIAL_GOOGLE_CLIENTID
clientSecret:TMH_SOCIAL_GOOGLE_SECRET];
if([auth canAuthorize]){

NSString * postString = @{\type \:\http:\\ / \\ / schemas.google.com\\ / AddActivity\,\ target\:{\ id\:\ tmhabc\,\ type\:\ http:\\\\ \\\\\\\\\\\\\\\\\\\\\\\\,\description\:\First post description\\,\name \:\First post \}};

NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@https://www.googleapis.com/plus/v1/people/me/moments/vault?access_token=%@& key =%@,auth.refreshToken,TMH_SOCIAL_GOOGLE_APIKEY]];
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
[request setValue:@application / jsonforHTTPHeaderField:@Content-Type];

GTMHTTPFetcher * myFetcher = [GTMHTTPFetcher fetcherWithRequest:request];

[myFetcher setAuthorizer:auth];
[myFetcher setPostData:[postString dataUsingEncoding:NSUTF8StringEncoding]];

[myFetcher beginFetchWithCompletionHandler:^(NSData * retrieveData,NSError * error){
if(error == nil){
NSLog(@OK%@,[[[ NSString alloc] initWithData:retrieveData encoding:NSUTF8StringEncoding]);
} else {
NSLog(@%@,error.localizedDescription);
}
}];
}

但收到错误401:操作无法完成。 (com.google.HTTPStatus错误401。)



我试试这个:


  1. 为Aplus Console中的Google Plus授予权限
  2. 授予范围 https://www.googleapis.com/auth/plus.login

  3. 在网上只找到这个答案: http://gusclass.com/blog/2013/02/27 / common-issues-for-the-new-google-platform-release / 这篇文章中的人建议使用data-requestvisibleactions(但是如何在目标c中做到这一点)

我不知道出了什么问题。


$ b 更新



https://developers.google.com/+/api/latest/moments/insert#try-it在插入时不起作用。

解决方案

遇到同样的问题,但在服务器端。您的oauth请求应该包含 request_visible_actions 参数,同时将用户重定向到认证页面。查看我的问题 diff for php client。


After Google authorization I try to post a moment without any confirmations:

GTMOAuth2Authentication *auth;
auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:TMH_SOCIAL_GOOGLE_KEYCHAIN
                                                             clientID:TMH_SOCIAL_GOOGLE_CLIENTID
                                                         clientSecret:TMH_SOCIAL_GOOGLE_SECRET];
if ([auth canAuthorize]) {

    NSString *postString = @"{\"type\":\"http:\\/\\/schemas.google.com\\/AddActivity\",\"target\":{\"id\":\"tmhabc\",\"type\":\"http:\\/\\/schemas.google.com\\/AddActivity\",\"description\":\"First post description\",\"name\":\"First post\"}}";

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.googleapis.com/plus/v1/people/me/moments/vault?access_token=%@&key=%@", auth.refreshToken, TMH_SOCIAL_GOOGLE_APIKEY]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

    GTMHTTPFetcher *myFetcher = [GTMHTTPFetcher fetcherWithRequest:request];

    [myFetcher setAuthorizer:auth];
    [myFetcher setPostData:[postString dataUsingEncoding:NSUTF8StringEncoding]];

    [myFetcher beginFetchWithCompletionHandler:^(NSData *retrievedData, NSError *error) {
        if (error == nil) {
            NSLog(@"OK %@", [[NSString alloc] initWithData:retrievedData encoding:NSUTF8StringEncoding]);
        } else {
            NSLog(@"%@", error.localizedDescription);
        }
    }];
}

But receive an error 401: The operation couldn’t be completed. (com.google.HTTPStatus error 401.)

I try this:

  1. Grant permissions for Google Plus in Apis Console
  2. Authorize with the scope "https://www.googleapis.com/auth/plus.login"
  3. In the Web found only this answer: http://gusclass.com/blog/2013/02/27/common-issues-for-the-new-google-platform-release/ guy in this post suggests to use "data-requestvisibleactions" (but how to do this in objective c)

I don't know what is wrong.

Update

https : //developers.google.com/+/api/latest/moments/insert#try-it does not work for moment insert.

解决方案

Got the same problem but on server side. Your oauth request should include request_visible_actions parameter while redirecting user to authentication page. Checkout my question and diff for php client.

这篇关于Google Plus无法发布片刻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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