0

I am trying to fetch the number of times a link is shared on google plus in my iOS app. I am trying the following code

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;

but it returns the following error

"Access Not Configured. The API (+1 API) is not enabled for your project. Please use the Google Developers Console to update your configuration."

Sakina Sugra
  • 195
  • 1
  • 11

2 Answers2

0

In Google Developers Console

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

  1. Select your project 2.Left Pane : Select Apis & Auth

There you can find so many API. Enable needed API.

Prakash
  • 90
  • 1
  • 8
0

It seems google no more allows the use of this api for public use. I found the answer here.

We now need to send a Get request to https://plusone.google.com/_/+1/fastbutton?url=http://www.facebook.com

Community
  • 1
  • 1
Sakina Sugra
  • 195
  • 1
  • 11