2015-10-20 58 views
0

我想获取在我的iOS应用中谷歌加分享链接的次数。我想下面的代码iOS获取谷歌加分享计数

NSString *post = @"[{\"method\":\"pos.plusones.get\",\"id\":\"p\",\"params\":{\"nolog\":true,\"id\":\"http://stylehatch.co/\",\"source\":\"widget\",\"userId\":\"@viewer\",\"groupId\":\"@self\"},\"jsonrpc\":\"2.0\",\"key\":\"p\",\"apiVersion\":\"v1\"}]"; 

NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; 

NSString *postLength = [NSString stringWithFormat : @"%lu",(unsigned long)[postData length]]; 

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 
[request setURL:[NSURL URLWithString:@"https://clients6.google.com/rpc?key=my_api_key"]]; 

[request setHTTPMethod:@"POST"]; 

[request setValue:postLength forHTTPHeaderField:@"Content-Length"]; 

[request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; 

[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; 

[request setHTTPBody:postData]; 

NSURLResponse *requestResponse; 

NSError *err; 

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&requestResponse error:&err]; 

return data; 

但它返回以下错误

“访问未配置的API(+1 API)是不是你的 项目启用。请使用谷歌开发者控制台更新您的 配置。“

回答

0

在谷歌开发者控制台

https://console.developers.google.com/project/googeplussignin/apiui/apis/library

  1. 选择项目 2.Left窗格:选择蜜蜂&验证

那里你可以找到这么多的API。启用所需的API。

+0

我已启用所有的谷歌加上API的需要 –

+0

http://stackoverflow.com/questions/22870082/getting-error-403-access-not-configured -please-use-google-developers-console-t 可能会有帮助 – Prakash

+0

没有给定的解决方案为我工作我已经尝试了一切:( –